#include <Servo.h>
#define ServoPin 3
#define Servo2Pin 5
int potenciometro = 0;
int boton = 0;
Servo pepito;
Servo2;
void setup() {
pepito.attach(ServoPin);
servo2.attach(Servo2Pin);
pinMode(4, INPUT);
}
void loop(){
potValue = analogRead(A0);
int servoPos = map(potValue, 0, 1023, 0, 180);
//Control the position of the second servo
servo2.write(servoPos);
//Read the button state
boton = digitalRead(4);
//If the button is pressed, move the first servo to the position of the second servo
if (buttonState == HIGH) {
servo.write(servoPos);
}
}
}