esp32-car/include/ultrasound.h

24 lines
366 B
C
Raw 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-01 19:22:37 +08:00
static void init(UltrasonicPin pin, int servoPin);
2024-12-27 09:47:56 +08:00
static float getDistance();
2025-01-01 19:22:37 +08:00
static int servoPin;
static Servo servo;
static void servoControl(int angle);
2024-12-27 09:47:56 +08:00
};
#endif