Eight Key Piano

Bring all eight keys into play and build a fully functioning piano. Now play some tunes!

Code

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.

Walkthrough Videos

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!

Challenges

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!

Concepts

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: 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.

Quiz

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

1. How many 'if' and 'else if' statements can you have in a single program?




2. If you hold down button 3 and button 5 at the same time, which note will play?