#include <Servo.h>
Servo servoMotor;
int servoPin = 9; // Pin connected to the servo motor
int button1Pin = 2; // Pin connected to the first push button
int button2Pin = 3; // Pin connected to the second push button
void setup() {
servoMotor.attach(servoPin);
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
}
void loop() {
if (digitalRead(button1Pin) == LOW) { // If button 1 is pressed
rotatePositive();
delay(1000); // Adjust this delay as needed
}
if (digitalRead(button2Pin) == LOW) { // If button 2 is pressed
rotateNegative();
delay(1000); // Adjust this delay as needed
}
}
void rotatePositive() {
servoMotor.write(90); // Rotate 90 degrees in positive direction
}
void rotateNegative() {
servoMotor.write(0); // Rotate 90 degrees in negative direction
}