// From: http://garagelab.com/profiles/blogs/how-to-use-tone-function-arduino-playing-the-james-bond-theme #include "pitches.h" #define NO_SOUND 0 // make the rests in music //array of notes int melody[] = { /*NOTE_G4,NOTE_G4,NO_SOUND,NOTE_G4,NOTE_G4,NO_SOUND,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4, NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3, NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4, NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,*/ //Introduction NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4, NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4, NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4, NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4, NOTE_DS5,NOTE_D5,NOTE_B4,NOTE_A4,NOTE_B4, NOTE_E4,NOTE_G4,NOTE_DS5,NOTE_D5,NOTE_G4,NOTE_B4, NOTE_B4,NOTE_FS5,NOTE_F5,NOTE_B4,NOTE_D5,NOTE_AS5, NOTE_A5,NOTE_F5,NOTE_A5,NOTE_DS6,NOTE_D6,NO_SOUND }; // note duration: 1 = whole note, 2 = half note, 4 = quarter note, 8 = eighth note, etc. int noteDurations[] = { /*8,8,2,8,8,2,16,8,16,8,8, 2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4, 8,16,16,8,4,8,8,8, 8,16,16,8,4,8,8,8,*/ 8,16,16,8,4,8,8,8, 8,16,16,8,4,8,8,8, 8,16,16,8,4,8,8,8, 8,16,16,8,4,8,8,8, 8,2,8,8,1, 8,4,8,4,8,8, 8,8,4,8,4,8, 4,8,4,8,3 }; int pace = 1450; // change pace of music("speedy") void setup() { for (int Note = 0; Note <54; Note++) {//counter of Notes (54 limit the array) int duration = pace/noteDurations[Note];//Adjust duration with the pace of music tone(9, melody[Note],duration); //Play note // to distinguish the notes, set a minimum time between them. delay(duration*1.2); } } void loop() { //to repeat song, push reset button. } //End of Sketch