#include Servo Servo1; Servo Servo2; const int PIN_ButtonController1Positive = 11; const int PIN_ButtonController1Negative = 13; const int PIN_ButtonController2Positive = 8; const int PIN_ButtonController2Negative = 10; const int PIN_LedController1 = 12; const int PIN_LedController2 = 9; const int PIN_Servo1 = 3; const int PIN_Servo2 = 5; int POSITION_Servo1 = 82; int POSITION_Servo2 = 90; void setup() { pinMode(PIN_ButtonController1Positive, INPUT); pinMode(PIN_ButtonController1Negative, INPUT); pinMode(PIN_ButtonController2Positive, INPUT); pinMode(PIN_ButtonController2Negative, INPUT); pinMode(PIN_LedController1, OUTPUT); pinMode(PIN_LedController2, OUTPUT); Servo1.attach(PIN_Servo1); Servo2.attach(PIN_Servo2); } void loop() { int STATE_ButtonController1Positive = digitalRead(PIN_ButtonController1Positive); int STATE_ButtonController1Negative = digitalRead(PIN_ButtonController1Negative); int STATE_ButtonController2Positive = digitalRead(PIN_ButtonController2Positive); int STATE_ButtonController2Negative = digitalRead(PIN_ButtonController2Negative); if((STATE_ButtonController1Positive == LOW)||(STATE_ButtonController1Negative == LOW)||(STATE_ButtonController2Positive == LOW)||(STATE_ButtonController2Negative == LOW)) { Servo1.write(POSITION_Servo1); Servo2.write(POSITION_Servo2); Servo1.detach(); Servo2.detach(); } if((STATE_ButtonController1Positive == HIGH)&&(POSITION_Servo1 < 180)) { Servo1.attach(PIN_Servo1); digitalWrite(PIN_LedController1, HIGH); Servo1.write(POSITION_Servo1); POSITION_Servo1++; delay(20); Servo1.detach(); digitalWrite(PIN_LedController1, LOW); } if((STATE_ButtonController1Negative == HIGH)&&(POSITION_Servo1 >= 0)) { Servo1.attach(PIN_Servo1); digitalWrite(PIN_LedController1, HIGH); Servo1.write(POSITION_Servo1); POSITION_Servo1--; delay(20); Servo1.detach(); digitalWrite(PIN_LedController1, LOW); } if((STATE_ButtonController2Positive == HIGH)&&(POSITION_Servo2 < 180)) { Servo2.attach(PIN_Servo2); digitalWrite(PIN_LedController2, HIGH); Servo2.write(POSITION_Servo2); POSITION_Servo2++; delay(20); Servo2.detach(); digitalWrite(PIN_LedController2, LOW); } if((STATE_ButtonController2Negative == HIGH)&&(POSITION_Servo2 >= 0)) { Servo2.attach(PIN_Servo2); digitalWrite(PIN_LedController2, HIGH); Servo2.write(POSITION_Servo2); POSITION_Servo2--; delay(20); Servo2.detach(); digitalWrite(PIN_LedController2, LOW); } }