Go Down

Topic: Playing " Happy Birthday to you" on Arduino (Read 1 time) previous topic - next topic

saroiane

Apr 09, 2015, 09:42 am Last Edit: Apr 10, 2015, 01:31 pm by saroiane
Hi Guys
I made this little code to play Happy Birthday melody.
It is simple though useful

here is the code

Code: [Select]
int pin[]= {523,523,587,523,698,659,0,   // Notes' array
           523,523,587,523,783,698,0,
           523,523,1046,880,689,658.25,587,
           932,932,880,698,783,698,0};
int time[]={500,500,1000,1000,1000,1000,1000, // time array in consequence with each note
           500,500,1000,1000,1000,1000,1000,
           500,500,1000,1000,1000,1000,2000,
           500,500,1000,1000,1000,1000,1000};

void setup(){}
void loop(){
 for (int No= 0; No<28; No++){  
 tone(13, pin[No], time[No]);
 delay (time[No]);
} // the 28 represent the note count
}


//I hope you like it

Go Up