String together notes to make a song. Once you have the basics, you can create any tune you can imagine!

The code in the editor below already works Just plug in your Code Piano and press upload to see what it does! Tinker with it and make changes to see what each line of code controls.

/*'Ascend to Charge', a popular song during baseball games C,E,G,A,E,G are the notes in order */ void setup(){ pinMode(10,OUTPUT); //Set the Speaker as an OUTPUT } void loop(){ tone(10,523); //C delay(150); //Play the note for 150 milliseconds tone(10,659); //E delay(150); tone(10,784); //G delay(150); tone(10,880); //A delay(300); //double delay on this note tone(10,659); //E delay(150); tone(10,784); //G delay(600); //quadruple delay on the last note noTone(10); delay(5000); //wait 5 seconds before replaying the song } // (c) 2018 Let's Start Coding. License:

Watch the videos for line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!


Can you complete the challenge? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

These are the new code concepts covered in this example program. To become a great coder, read through these concepts to learn new vocabulary.

New Concept: Real-world crossover with code

Code is often created to reflect something from the ‘real world’, just like this program. It’s very easy to look up the hertz value of a piano note and convert it to a tone command you can use to build songs on your Code Piano. There are some things, like chords, that you aren’t able to play on your Code Piano. But there are some things, like playing at extremely high speeds with 100% accuracy, that are much easier to do on Code Piano than on a real piano!


If you're having trouble, try to run an experimental program or look at the example code to help you find the answer.

1. True or False: You have to use a noTone() command between every note that plays on Code Speaker.