const int buttonPin = 2;
const int ledPin = 13
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(buttonPin)==LOW){
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000);
delay(100);
}
else{
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
}
}