const int buzzer=8;
const int led=9;
const int pushbutton=10;
int pushbuttonstate=0;
void setup() {
Serial.begin(115200);
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
pinMode(pushbutton, INPUT);
}
void loop() {
digitalWrite(led,HIGH);
pushbuttonstate=digitalRead(pushbutton);
if (pushbuttonstate==HIGH)
{
digitalWrite(buzzer, HIGH);
tone(buzzer,900);
delay(500);
tone(buzzer,800);
delay(1000);
}
else {
digitalWrite(buzzer,LOW);
noTone(buzzer);
}
}