#include "ESP32Servo.h"
struct ServoPins
{
Servo servo;
int servoPin;
String servoName;
int initialPosition;
};
std::vector<ServoPins> servoPins =
{
{ Servo(), 12 , "Base", 90},
{ Servo(), 14 , "Ombro", 90},
{ Servo(), 13 , "Cotovelo", 90},
{ Servo(), 27 , "Garra", 0},
};
unsigned long previousTimeInMilli = millis();
void setUpPinModes()
{
for (int i = 0; i < servoPins.size(); i++)
{
servoPins[i].servo.attach(servoPins[i].servoPin);
servoPins[i].servo.write(servoPins[i].initialPosition);
}
}
void setup(void)
{
setUpPinModes();
Serial.begin(115200);
}
void loop()
{
for ( int i=0; i<120; i++){
servoPins[0].servo.write(i);
delay(10);
}
for ( int i = 120; i>0; i--){
servoPins[0].servo.write(i);
delay(10);
}
}