Hi im trying to use the servo with my esp32s but it does not work and the error code im getting is the following:
In file included from C:\Users\hacke\AppData\Local\Temp\.arduinoIDE-unsaved2023824-24352-n4hf7f.uateh\01-SimpleServo\01-SimpleServo.ino:1:
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:68:81: error: call to non-'constexpr' function 'const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]'
static const int TIMER_RESOLUTION = std::min(16, SOC_LEDC_TIMER_BIT_WIDE_NUM);
^
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h: In member function 'T ServoTemplate<T>::mapTemplate(T, T, T, T, T) const':
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:28: error: 'is_floating_point_v' is not a member of 'std'
if constexpr (std::is_floating_point_v<T>) {
^~~~~~~~~~~~~~~~~~~
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:28: note: suggested alternative: 'is_floating_point'
if constexpr (std::is_floating_point_v<T>) {
^~~~~~~~~~~~~~~~~~~
is_floating_point
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:49: error: expected primary-expression before '>' token
if constexpr (std::is_floating_point_v<T>) {
^
c:\Users\hacke\Documents\Arduino\libraries\ServoESP32\src/Servo.h:256:50: error: expected primary-expression before ')' token
if constexpr (std::is_floating_point_v<T>) {
^
exit status 1
Compilation error: exit status 1
I do not know the reason for this and any help or suggestion would be major. Thank you and hope you guys are having a good day.
Include the attached Libray with the IDE and then upload the following example taken from IDE's Examples. Report the result. I attached a very old SG90 Servo, but it turns intermittently. Use seperate 5V power supply as the Servo takes about 100 - 250 mA during movement with load; whereas, ESP32's pin can supply max 40 mA (recommended use is 20 mA).
#include <ESP32Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0;
int servoPin = 13;
void setup()
{
// Allow allocation of all timers
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
myservo.setPeriodHertz(50); // standard 50 hz servo
myservo.attach(servoPin, 1000, 2000); // attaches the servo on pin 18 to the servo object
}
void loop()
{
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}