const int buzzerPin = 9; // Define the buzzer pin
void setup() {
pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as an OUTPUT
}
void loop() {
playTone(buzzerPin, 1000, 500); // Play a tone at 1000 Hz for 500 ms
delay(500); // Pause for 500 ms
playTone(buzzerPin, 1500, 500); // Play a tone at 1500 Hz for 500 ms
delay(500); // Pause for 500 ms
playTone(buzzerPin, 2000, 500); // Play a tone at 2000 Hz for 500 ms
delay(1000); // Pause for 1 second
}
void playTone(int pin, int frequency, int duration) {
tone(pin, frequency); // Start the tone
delay(duration); // Delay for the specified duration
noTone(pin); // Stop the tone
}