It compiles & uploads, so it would seem so - haven't tried connecting a speaker yet to hear it.
// info on alarm sound
#include "pitches.h"
// notes in the melody:
int thisNote = 0;
int noteDuration = 0;
int pauseBetweenNotes = 0;
int melody[] = {
NOTE_C6, NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
0xffffffff,12,12,12,12,12,4};
void setup(){}
void loop(){
for (thisNote = 0; thisNote < 8; thisNote++)
{
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
// noteDuration = 1000/noteDurations[thisNote];
noteDuration =noteDurations[thisNote];
noTone(6); //apparent known bug - need this for the tone to play next.
tone(6, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// using the note's duration + 10%:
pauseBetweenNotes = noteDuration * 1.10;
delay(pauseBetweenNotes);
// stop the tone playing:
// noTone(6);
}
}