Professional Documents
Culture Documents
Juanrohanfinal
Juanrohanfinal
Juanrohanfinal
pinMode(buzzerPin, OUTPUT);
//buzzerPin is the output
}
void loop()
{
while(true){}
// This determines if you want to stop the song after one play or not
}
int i; // integer i
const int numNotes = 24; // number of notes stored
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'D', 'E', 'F',
'G', 'A', 'B', '!', '_', 'q', 't', 'y', 'i', 'p', 'W', 'S', 'T'};
//these are the notes which are associated with letters
int frequencies[] = {262, 294, 311, 349, 392, 440, 466, 523, 587, 622, 698,
784, 880, 988, 1047, 196, 233, 175, 208, 415, 466, 740, 831, 494};
// These arrays hold the characters and their corresponding hertz. For
example, 'c' is 262 and 'T' is 494.
// The code will get the letter and search for the hertz and return it
for (i = 0; i < numNotes; i++) // The song is not going to stop until all
of the notes are played
{
if (names[i] == note) // If the name is equal to the note then
return the frequency
{
return(frequencies[i]); //return the frequencies with the counter
}
}
return(0); // return nothing
}