Shave and A Haircut - Code Song

The classic “Shave and a Haircut” song written in code. We recommend that you’ve followed the projects up to at least speaker project 8 so you’ll have an understanding of how this song is coded with variables. Start here and tinker, modify, and update to make your own version or your own completely new song!

//'Shave and a Haircut' int G = 392; int A = 440; int B = 494; int C = 523; int E = 659; //C,G,G,A,G,(rest),B,C int noteDuration = 280; //how long each note plays void setup(){ pinMode(10,OUTPUT); //Set the Speaker as an OUTPUT } void loop(){ tone(10,C); delay(noteDuration); tone(10,G); delay(noteDuration/2); noTone(10); delay(10); tone(10,G); delay(noteDuration); tone(10,A); delay(noteDuration); tone(10,G); delay(noteDuration); noTone(10); delay(noteDuration*1.5); tone(10,B); delay(noteDuration); tone(10,C); delay(noteDuration); noTone(10); delay(5000); //wait 5 seconds before replaying the song } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense