#define buzzer 4
void setup()
{
pinMode(buzzer, OUTPUT);
}
void loop()
{
tone(buzzer,10000,1000); //Using tone function with duration
//tone(buzzer,10000); //Using tone function without duration
delay(2000);
noTone(buzzer);
delay(1000);
}