esp32-car/include/ultrasound.h

26 lines
405 B
C
Raw Permalink Normal View History

2024-12-27 09:47:56 +08:00
#ifndef ULTRASOUND_H
#define ULTRASOUND_H
#include <Arduino.h>
2025-01-01 19:22:37 +08:00
#include <ESP32Servo.h>
2024-12-27 09:47:56 +08:00
struct UltrasonicPin
{
int trig;
int echo;
};
struct Ultrasonic
{
static UltrasonicPin pin;
2025-01-02 02:19:07 +08:00
static float distance;
2025-01-01 19:22:37 +08:00
static void init(UltrasonicPin pin, int servoPin);
2025-01-02 02:19:07 +08:00
static void update();
2025-01-01 19:22:37 +08:00
static int servoPin;
2025-01-02 02:19:07 +08:00
static int angle;
2025-01-01 19:22:37 +08:00
static Servo servo;
static void servoControl(int angle);
2024-12-27 09:47:56 +08:00
};
#endif