#include <Servo.h>
const int buttonPin = 2; // Digital input pin for the push button
const int servoPin = 9; // Analog output pin for the servo motor
Servo myServo;
void setup() {
pinMode(buttonPin, INPUT);
myServo.attach(servoPin);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
myServo.write(90); // Rotate the servo to 90 degrees (or any desired position)
delay(500); // Wait for a second
} else {
myServo.write(0); // Rotate the servo to 0 degrees (or any other resting position)
}
}