#include <Servo.h>
#define ON_BTN_PIN 7
#define OFF_BTN_PIN 8
#define SERVO_PIN 6
#define HOME_POSITION 90
#define ON_POSITION 35
#define OFF_POSITION 155
Servo arm;
void setup() {
pinMode(ON_BTN_PIN, INPUT_PULLUP);
pinMode(OFF_BTN_PIN, INPUT_PULLUP);
arm.attach(SERVO_PIN);
arm.write(HOME_POSITION);
}
void loop() {
if(digitalRead(ON_BTN_PIN) == LOW) {
arm.write(ON_POSITION);
delay(1000);
arm.write(HOME_POSITION);
}
if(digitalRead(OFF_BTN_PIN) == LOW) {
arm.write(OFF_POSITION);
delay(1000);
arm.write(HOME_POSITION);
}
delay(100);
}
OFF
ON
______________________________