Send out soundwaves with the ‘Save Our Ship’ Morse code message through the speaker on your rocket in case there is trouble when landing on a new planet.

The code in the editor below already works Just plug in your Code Rocket and press upload to see what it does! Tinker with it and make changes to see what each line of code controls.

/*Play a Morse Code message on the speaker Rules of Morse Code: - Dots are 1 'unit' of sound - Dashes are 3 'units' of sound (3 times as long as a dot) - Spaces between symbols within the same letter are 1 'unit' of silence - Spaces between letters are 3 'units' of silence - Spaces between words are 7 'units' of silence */ void setup(){ pinMode(2,OUTPUT); //Set the speaker as an 'OUTPUT' } void loop(){ //S //dot tone(2,500); //play a tone of 500 hertz on the speaker (2) delay(300); //wait one 'dot' with the speaker on noTone(2); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(2,500); //play a tone of 500 hertz on the speaker (2) delay(300); //wait one 'dot' with speaker on noTone(2); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(2,500); //play a tone of 500 hertz on the speaker (2) delay(300); //wait one 'dot' with speaker on noTone(2); //turn off the sound delay(900); //wait before the next letter in a word //O //dash tone(2,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with speaker on noTone(2); //turn off the sound delay(300); //wait before the next symbol in a letter //dash tone(2,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with the speaker on noTone(2); //turn off the sound delay(300); //wait before the next symbol in a letter //dash tone(2,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with speaker on noTone(2); //turn off the sound delay(900); //wait before the letter in a word //S //dot tone(2,500); //play a tone of 500 hertz on the speaker (2) delay(300); //wait one 'dot' with the speaker on noTone(2); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(2,500); //play a tone of 500 hertz on the speaker (2) delay(300); //wait one 'dot' with the speaker on noTone(2); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(2,500); //play a tone of 500 hertz on the speaker (2) delay(300); //wait one 'dot' with the speaker on noTone(2); //turn off the sound delay(2100); //wait before the next word } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

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!


Challenge

Can you complete the challenges? Change the code in the editor above, then upload it to your Code Rocket and see if you got the result. Check the box next to the challenge to 'mark it off' once it's complete. Don't stop here, keep experimenting with the code!


*International_Morse_Code.PNG

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: One challenge, many solutions

In programming, there are many approaches to one challenge or problem. Here, you’re sending the same Morse code message as you did in the last project, but using different capabilities on Code Rocket to do it. As you building your coding skills, you may think of new ways to solve a problem that you didn’t think of before. There isn’t just one ‘right’ way to solve a challenge, so get creative! Who knows, you may find a way nobody has thought of before.


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 would you double the speed of your Morse code message?