Convert your piano notes to hertz values one time, then use your variables throughout the code to quickly create whatever song you’d like!
The code in the editor below already works. Just plug in your Code Speaker 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: Variables- one step further.
Here, you’ve taken variables to the next level, using them in place of any number that is likely to change as you modify your song or create a new song. Now that you have some of the common notes mapped out, you could change the void loop() very quickly to create different tunes. As programs grow more complex, you may see fewer and fewer ‘hard-coded’ values and more variable values that replace those numbers.