Good morning all,
I have been fiddling about trying to use this library for servo control functions. I how ever can't get any servo's to move. I have read as much as I can find online about the library, I'm still not sure how to setup the program to operate even a single servo. I have used Servo.h in the past successfully, I now am trying to get a handle on ESP32servo. Some assistance please with organizing a servo to sweep, or rotate and stop.
#include <ESP32Servo.h>
//#include "BluetoothSerial.h"
//#include <Esp32WifiManager.h> // https://github.com/tzapu/WiFiManager
#define pitch 5
#define yaw 8
#define roll 10
#define Angle_4 11
#define Left_Aileron 12
#define Right_Aileron 13
#define Rudder 14
#define Elevator 15
#define Trim_Left 16
#define Trim_Right 17
#define SpeedController 18
void setup() {
// BluetoothSerial SerialBT;
Serial.begin(115200);
// SerialBT.begin("ESP32test"); //Bluetooth device name
// Serial.println("The device started, now you can pair it with bluetooth!");
Servo Left_Servo_Aileron;
Servo Right_Servo_Aileron;
Servo Trim_L;
Servo Trim_R;
Servo Elevator_Pos;
Servo Rudder_Pos;
Servo MotorSpeedController;
Left_Servo_Aileron.setPeriodHertz(50);
Left_Servo_Aileron.attach(Left_Aileron,1000,2500);
// Servo::setTimerWidth(16);
Left_Servo_Aileron.setTimerWidth(16);
Left_Servo_Aileron.write(450);
Left_Servo_Aileron.Servo::writeMicroseconds (2000);
// Left_Servo_Aileron.read(); // Gets the last written servo pulse width as an angle between 0 and 180.
Left_Servo_Aileron.readTimerWidth(); // Gets the PWM timer width (ESP32 ONLY)
Serial.println(Left_Servo_Aileron.readTimerWidth());
}
// We are using "Left_Aileron" pin 12
void loop() {
// Left_Servo_Aileron.write(1450);//
// Left_Servo_Aileron.setTimerWidth(15);
// Left_Servo_Aileron.writeMicroseconds (1450);
// for (int pos = 0; pos <= 180; pos += 1) {
// delay(14); // waits 15 ms for the servo to reach the position
// Time = micros();
// Time = millis();
// if (Time <= 20) {
// Serial.println(is_attached[0]);
// }
// else {
// Serial.println("Done");
// }
}