I am working on this tutorial,
https://www.hackster.io/SURYATEJA/morse-code-communication-using-laser-module-both-ea1b01
and the author created a "Send" and "Receive" code for encoding and decoding Morse code. He created the "Send" code with the entire alphabet A-Z, but his receive code only has 9 letters.
I thought I could easily add in the missing characters, and even add in numbers, but I am stuck.
His code has 2 values to decode the morse - "a" and "f"
In his receive code he has a value "f" that is supposed to be calculated by the number of spaces, but I cannot see how he comes up with his result.
For example, this is his sending code for "a"
case 'a':
MorseDot();
LightsOff(elemPause);
MorseDash();
LightsOff(elemPause);
break;
Then this is the receive code;
if(a==4 && f==10) { Serial.print("a");
I understand the value of 4 for "a", but I cannot understand the value of 10 for "f"
"a" is calculated by assigning a value of 1 for a dot and 3 for a dash and adding the values (in this case one dot and one dash, 1+3 = 4)
He explains how to calculate "f" here in his tutorial, but I still don't understand.
When the LASER falls on the LDR, the value goes beyond 1000, and then it will enter into a loop.
Now quantize the values i.e. if the value goes beyond 1000, then assign it as '1', otherwise assign it as '0'.
Inside a loop, calculate the number of '1's and '0's. Set the counters 'a' and 'f'. Count the number of '1's and store it in 'a' and similarly count the number of '0's and store it in 'f' respectively.
Now check the specific values of 'a' and 'f' respectively. Each character will have different set of 'a' and 'f'. The matching value will be displayed.
That seems to indicate; Laser on = Over 1000 = 1 Laser off = Under 1000 = 0
So for the letter a, I only see 2 times the laser goes off, not 10.Minof formatting changes
case 'a':
block that you included in your question .... thecase 'a':
should not be indented and the next four lines should be indented ..... all the othercase
statement blocks should be formatted the same way ...................... theLightsOff(elemPause);
should not be called inside thecase
blocks .... it should be called at the end ofMorseDot()
andMorseDash()
functions ..... that would reduce the length of the program significantly