Bring all eight keys into play and build a fully functioning piano. Now play some tunes!
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.
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!
New Concept: Looking for patterns
If you’ve done the last project, you’re probably seeing the patterns that continue into this project, too. Just like your Morse code message, understanding this program is about understanding that there are ‘building blocks’ in it that are repeated over and over. If you had 100 buttons, you could code them all to have a different tone by using the same pattern that you see in this project.
Remember that the computer doesn’t care about line breaks, indenting, or comments, but as you start to repeat lines of code over and over, those become important tools. If your code is a jumbled mess, it gets harder and harder to see the patterns and to modify them when you’re ready to make a change.