#include <Servo.h>
const int buttonPin = 2; // Digital input pin for the push button
const int buzzerPin = 3; // Digital output pin for the buzzer
const int servoPin = 9; // Analog output pin for the servo motor
Servo myServo;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(buzzerPin, OUTPUT);
myServo.attach(servoPin);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
// Rotate the servo to 90 degrees
myServo.write(90);
// Turn on the buzzer
digitalWrite(buzzerPin, HIGH);
delay(1000); // Wait for a second
// Rotate the servo to 0 degrees
myServo.write(0);
// Turn off the buzzer
digitalWrite(buzzerPin, LOW);
}
}