Rocket Morse Code Part Two Bug Hunt! Test your Troubleshooting.

You may have already run into some errors in modifying or writing your own code. Don't worry, studies have shown that almost half of all code 'compiles' result in an error! 

The code below has some errors sprinkled in it. Before you run the code, read through it and look for the errors, called bugs. Can you find them? Try to fix each one and then see if the code runs. 

/*Buggy: 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
 



Need a hint? Click here.