Use buttons to ‘tune in’ the pitch of a variable note or hold them down to create fun sound effects.
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!
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: Changing variable values
So far, you’ve used variables as ‘names for numbers’ that made your code easier to change and update by programmers. In this project, you instead use a variable as a number that can be changed by the code and doesn’t have a constant value as the code runs. This is another important feature of variables - you can update them as the code runs.
It’s almost impossible to keep track of the value of the pitch variable in this code because it can change so quickly, but try to imagine what value ‘pitch’ has as you play with this project. If you can visualize the value of a variable that you’re using, it’s much easier to find and solve problems that can come up when you’re using them in place of number values.