diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b9f42da --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,35 @@ +#include +#include + +const int serialBaud = 115200; + +ESP32PWM pwm; +const int pwmTimer = 0; +Servo servo; +const int servoPin = 14; // Pin wired up to the servo data line +const int servoFrequency = 50; + +// Published values for Emax ES08MA II +const int minUs = 1500; +const int maxUs = 1900; + +void setup() { + Serial.begin(serialBaud); + + ESP32PWM::allocateTimer(pwmTimer); + + servo.setPeriodHertz(servoFrequency); + servo.attach(servoPin, minUs, maxUs); +} + +void loop() { + for (uint8_t i = 0; i < 10; i += 1) { + servo.write(i*10); + delay(1000); + } +} + +void end() { + servo.detach(); + pwm.detachPin(servoPin); +}