const int BUZZER = 3; // Buzzer connected to digital pin 3
void setup() {
// Set the buzzer pin as an output
pinMode(BUZZER, OUTPUT);
}
void loop() {
// Play the "Twinkle Twinkle Little Star" melody
// Note: The "<<" operator is used to play the notes at a higher octave
tone(BUZZER, 262 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 262 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 392 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 392 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 440 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 440 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 392 << 3);
delay(1000);
noTone(BUZZER);
delay(1000);
tone(BUZZER, 349 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 349 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 330 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 330 << 3);
delay(500);
noTone(BUZZER);
delay(500);
tone(BUZZER, 294 << 3);
delay(1000);
noTone(BUZZER);
delay(1000);
}