Speaker Morse Code: Part One Bug Hunt! Test your Troubleshooting.

This code will upload to Code Speaker, but it won’t run as you expect it to. Can you find out what’s causing the problem?

/*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(10,OUTPUT); //Set the speaker as an 'OUTPUT' } void loop(){ //S //dot tone(10,500); //play a tone of 500 hertz on the speaker delay(300); //wait one 'dot' with the speaker on noTone(10); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(10,500); //play a tone of 500 hertz on the speaker delay(300); //wait one 'dot' with speaker on noTone(10); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(10,500); //play a tone of 500 hertz on the speaker delay(300); //wait one 'dot' with speaker on noTone(10); //turn off the sound delay(900); //wait before the next letter in a word //O //dash tone(10,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with speaker on noTone(10); //turn off the sound delay(300); //wait before the next symbol in a letter //dash tone(10,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with the speaker on noTone(10); //turn off the sound delay(300); //wait before the next symbol in a letter //dash tone(10,500); //play a tone of 500 hertz delay(900); //wait one 'dash' with speaker on noTone(10); //turn off the sound delay(900); //wait before the letter in a word //S //dot tone(10,500); //play a tone of 500 hertz on the speaker delay(300); //wait one 'dot' with the speaker on noTone(10); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(10,500); //play a tone of 500 hertz on the speaker delay(300); //wait one 'dot' with the speaker on noTone(10); //turn off the sound delay(300); //wait before the next symbol in a letter //dot tone(10,500); //play a tone of 500 hertz on the speaker delay(300); //wait one 'dot' with the speaker on //noTone(10); //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.