#include // --- Servo 1 --- const int servoPin1 = 28; const int buttonPin1 = 6; Servo myServo1; const int restPos1 = 0; const int hitPos1 = 180; // --- Servo 2 --- const int servoPin2 = 27; const int buttonPin2 = 0; Servo myServo2; // Invertido const int restPos2 = 180; const int hitPos2 = 0; // Estado anterior de los botones int lastButtonState1 = HIGH; int lastButtonState2 = HIGH; void setup() { Serial.begin(115200); pinMode(buttonPin1, INPUT_PULLUP); pinMode(buttonPin2, INPUT_PULLUP); myServo1.attach(servoPin1); myServo2.attach(servoPin2); myServo1.write(restPos1); myServo2.write(restPos2); delay(500); lastButtonState1 = digitalRead(buttonPin1); lastButtonState2 = digitalRead(buttonPin2); } void loop() { int currentButtonState1 = digitalRead(buttonPin1); int currentButtonState2 = digitalRead(buttonPin2); // --- Botón 1 --- if (lastButtonState1 == HIGH && currentButtonState1 == LOW) { delay(20); if (digitalRead(buttonPin1) == LOW) { Serial.println("SERVO 1"); myServo1.write(hitPos1); delay(300); myServo1.write(restPos1); } } // --- Botón 2 --- if (lastButtonState2 == HIGH && currentButtonState2 == LOW) { delay(20); if (digitalRead(buttonPin2) == LOW) { Serial.println("SERVO 2"); myServo2.write(hitPos2); delay(300); myServo2.write(restPos2); } } lastButtonState1 = currentButtonState1; lastButtonState2 = currentButtonState2; }