Use the Speaker as a communications device, programming in a message to beep out in Morse code.
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: Writing code for humans to read
When the computer reads your program, it doesn’t care about line breaks or comments. But in this program, you can imagine how confusing it would be to try and read or modify the code without comments breaking the Morse code message into letters and characters. Once you do that, it’s easy for a programmer like yourself to read through the code and figure out what is happening.
Practice updating your code comments when you’re writing programs. It will help you if you return to a program that you wrote in the past and it will help you clarify your thoughts about what you’re writing.