#include Servo myservo; const int buttonPin = 9; int val; int buttonState = 0; void setup() { myservo.attach(2); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { val = 90; } else { val = 0; } myservo.write(val); delay(15); }