Who loves flashing and beeping? Everyone! Here’s an example of Morse code with Gadgeteer. Use this project to teach microcontroller programming and Morse code at the same time. Even the adults seem to like the flashing and the beeping. It’s fun to send simple words and who can decipher it first. You’ll be amazed at how fast kids pick up being able to decipher Morse code in their heads.
Here’s an example with “Hi there” (warning… audio beeps):
Source is here:
https://github.com/wbsimms/GMorse
The wiring is very simple. You need:
- A microcontroller
- A breadboard
- An LED
- A piezo speaker
Learning the rules for morse code is most of the fun. Wikipedia has a great article on but the rules are simple.
- The length of a dot it one unit
- A dash is three units
- The space between parts of the same letter is one unit
- The space between letters is three units
- The space between words is seven units
The code is pretty simple for this:
private void Dot() { signalOutput.Write(true); Thread.Sleep(delayInterval); signalOutput.Write(false); Thread.Sleep(delayInterval); } private void Dash() { signalOutput.Write(true); Thread.Sleep(delayInterval * 3); signalOutput.Write(false); Thread.Sleep(delayInterval); } private void LetterEnd() { Thread.Sleep(delayInterval * 3); } private void WordEnd() { Thread.Sleep(delayInterval * 7); }
Once you have this, you just need to write the dots and dashes for each letter:
public void PlayCode(char character) { switch (character.ToLower()) { case 'a': Dot();Dash();return; case 'b': Dash();Dot();Dot();Dot();return; case 'c': Dash();Dot();Dash();Dot();return; case 'd': Dash();Dot();Dot(); return; ...
A fun improvement would be allow to change the delayInterval and see how fast you can read Morse.
The TouchKeyboard project is here:
https://github.com/wbsimms/TouchKeyboard
NB: I’m using a custom version of Gadgeteer.dll in this example for the screen. There’s a defect DisplayModule.cs