#define buzzer 10
int button = 9;
bool tombol = false;
void setup() {
// put your main code here, to run once:
pinMode(buzzer, OUTPUT);
pinMode(button, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
tombol=digitalRead(button);
if(tombol==HIGH)
{
tone(buzzer, 500);
}
else
{
noTone(buzzer);
}
}