Morse Code Part One 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 a very sly set of bugs built in. The code will run, but not quite as you expect. Use the graphic for the Morse code characters to help you figure out what is wrong here.

/*Buggy: Flash out a Morse Code message on an LED light 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(6,OUTPUT); //Set the LED as an 'OUTPUT' } void loop(){ //S //dot digitalWrite(6,LOW); //Turn on LED 6 delay(300); //wait one 'dot' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(300); //wait before the next symbol in a letter //dot digitalWrite(6,LOW); //Turn on LED 6 delay(300); //wait one 'dot' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(300); //wait before the next symbol in a letter //dot digitalWrite(6,LOW); //Turn on LED 6 delay(300); //wait one 'dot' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(900); //wait before the next letter in a word //O //dash digitalWrite(6,LOW); //Turn on LED 6 delay(900); //wait one 'dash' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(300); //wait before the next symbol in a letter //dash digitalWrite(6,LOW); //Turn on LED 6 delay(900); //wait one 'dash' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(300); //wait before the next symbol in a letter //dash digitalWrite(6,LOW); //Turn on LED 6 delay(900); //wait one 'dash' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(900); //wait before the next letter in a word //S //dot digitalWrite(6,LOW); //Turn on LED 6 delay(300); //wait one 'dot' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(300); //wait before the next symbol in a letter //dot digitalWrite(6,LOW); //Turn on LED 6 delay(300); //wait one 'dot' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(300); //wait before the next symbol in a letter //dot digitalWrite(6,LOW); //Turn on LED 6 delay(300); //wait one 'dot' with LED on digitalWrite(6,HIGH); //Turn off LED 6 delay(2100); //wait before the next word in a message } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

*International_Morse_Code.PNG



Need a hint? Click here.