Introduction: Arduino Morse Code

When I was younger I started practicing for my Ham Radio license but did not stick with this long enough to master the morse code. With this project you can convert any text to morse code. This project will show you how to create a basic circuit which converts the text to morse code and blinks LED lights while playing audio of the translated dots and dashes.

This is my first Instructables project so I hope you like it! In this project I will assume you have some very basic knowledge of electronics and uploading code to the Arduino. Check out many other great Instructables for help on this if necessary. This is a really easy project so I'm sure you will not have any issues.

Step 1: Gather the Parts

For this project use an Arduino Uno micro controller connected to a solderless breadboard.

  • 1 - Andruino
  • 1 - Solderless Breadboard
  • 3 - Resistors (220 Ohm)
  • 1 - 8-ohm Mini Speaker
  • 2 - 5mm LED Lights
  • 3 - Short Jumper Wires (1 cm)
  • 4 - Longer Jumper Wires (6 - 10 cm)
  • 1 - USB Cable

Step 2: Setup the Circuit Board

First setup the breadboard to connect the two LEDs and one speaker as seen in the wiring diagram. Connect the small jumper from the ground to one row. On a second row connect a longer jumper cable and a resistor. The LED light or speaker will bridge these two rows. When connecting the LEDs, the positive leg (longer of the two wires coming out of the LED) should be connected to the line with the resistor and the negative leg will be on the grounded row.

Step 3: Connecting the Arduino

Now that you have the breadboard wired you will connect this to the Arduino. In the code we will be using output pins six and twelve for the LED lights and pin eight for the audio. Connect the two longer jumper wires with the LEDs inline to pin six and twelve on the Arduino. Connect the longer jumber wire with the speaker to pin eight. Finally, connect the GND pin to the ground bus at the top of the breadboard.

Step 4: Uploading the Code

Next connect your computer to the Arduino via the USB cable. Using the Arduino compiler upload the following code. To modify the morse code string just change the 'stringToMorseCode'. The code will read this string and convert the string to morse code, both visual and audio.

The code reads the string to an array and then using the GetChar function this converts each character into dots and dashes. Currently this is just converting alphabetic characters but you can easily add additional characters (numbers, punctuation) in this select statement switch at the bottom of the code.

/*
Morse Code Project This code will loop through a string of characters and convert these to morse code. It will blink two LED lights and play audio on a speaker. */ //**************************************************// // Type the String to Convert to Morse Code Here // //**************************************************// char stringToMorseCode[] = "Arduino Morse Code Project";

// Create variable to define the output pins int led12 = 12; // blink an led on output 12 int led6 = 6; // blink an led on output 6 int audio8 = 8; // output audio on pin 8 int note = 1200; // music note/pitch

/* Set the speed of your morse code Adjust the 'dotlen' length to speed up or slow down your morse code (all of the other lengths are based on the dotlen)

Here are the ratios code elements: Dash length = Dot length x 3 Pause between elements = Dot length (pause between dots and dashes within the character) Pause between characters = Dot length x 3 Pause between words = Dot length x 7 http://www.nu-ware.com/NuCode%20Help/index.html?m... */ int dotLen = 100; // length of the morse code 'dot' int dashLen = dotLen * 3; // length of the morse code 'dash' int elemPause = dotLen; // length of the pause between elements of a character int Spaces = dotLen * 3; // length of the spaces between characters int wordPause = dotLen * 7; // length of the pause between words

// the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output for LED lights. pinMode(led12, OUTPUT); pinMode(led6, OUTPUT); }

// Create a loop of the letters/words you want to output in morse code (defined in string at top of code) void loop() { // Loop through the string and get each character one at a time until the end is reached for (int i = 0; i < sizeof(stringToMorseCode) - 1; i++) { // Get the character in the current position char tmpChar = stringToMorseCode[i]; // Set the case to lower case tmpChar = toLowerCase(tmpChar); // Call the subroutine to get the morse code equivalent for this character GetChar(tmpChar); } // At the end of the string long pause before looping and starting again LightsOff(8000); }

// DOT void MorseDot() { digitalWrite(led12, HIGH); // turn the LED on digitalWrite(led6, HIGH); tone(audio8, note, dotLen); // start playing a tone delay(dotLen); // hold in this position }

// DASH void MorseDash() { digitalWrite(led12, HIGH); // turn the LED on digitalWrite(led6, HIGH); tone(audio8, note, dashLen); // start playing a tone delay(dashLen); // hold in this position }

// Turn Off void LightsOff(int delayTime) { digitalWrite(led12, LOW); // turn the LED off digitalWrite(led6, LOW); noTone(audio8); // stop playing a tone delay(delayTime); // hold in this position }

// *** Characters to Morse Code Conversion *** // void GetChar(char tmpChar) { // Take the passed character and use a switch case to find the morse code for that character switch (tmpChar) { case 'a': MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'b': MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'c': MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'd': MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'e': MorseDot(); LightsOff(elemPause); break; case 'f': MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'g': MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'h': MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'i': MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'j': MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'k': MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'l': MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'm': MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'n': MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'o': MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'p': MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 'q': MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'r': MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 's': MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; case 't': MorseDash(); LightsOff(elemPause); break; case 'u': MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'v': MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'w': MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'x': MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'y': MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); break; case 'z': MorseDash(); LightsOff(elemPause); MorseDash(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); MorseDot(); LightsOff(elemPause); break; default: // If a matching character was not found it will default to a blank space LightsOff(Spaces); } }

/* Unlicensed Software: This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to */

Step 5: Testing the Project

Now the fun part, test it out! The code will play through the morse code string and then pause for several seconds before looping again. Play around with code and circuit layout. Try adding a few extra lights in parallel with each other. Also play around with the code by changing the "dotLen" variable to adjust the length of the dots and dashes (speeds up/slows down the morse code). Change the "note" variable to adjust the audio pitch.

Let me know how this works for you and if you have any improvements!

Chris Weatherford

Comments

author
JonG83 made it! (author)2017-05-23

Works great now, had to tweak the program a little though.

Changed int Spaces = dotLen * 3 to int charPause = dotLen * 3;

Then changed the last line of each character from LightsOff(elemPause);

to LightsOff(charPause);

Added numbers, punctuation and pro-signs. Used two different color LEDs, blue and red, changed program so blue blinks on dashes and red blinks on dots

author
lo0ping84 made it! (author)2014-11-30

hi ,
"D" is wrong, it should be "dash dot dot".

int Spaces = dotLen * 3 - dotLen;

//also need add extra code in loop.
if(i > 0 && i < sizeof(stringToMorseCode) - 1) {//elementPause

noTone(audio8);

delay(dotLen);

}

author
suade907 made it! (author)suade9072017-05-10

I noticed there are problems with this code not pausing between letters as well. Like S and H there is 0 pause between them. Where did you put your if statement I keep getting errors no matter where I stick it.

author
JimRD made it! (author)2017-03-25

Thanks Chris. I used your code in what will soon be an Instructable. You did all the heavy lifting for me and I had your code running right away.

author
c_rand made it! (author)2016-12-16

thanks for posting this ! i just posted my first project here and your code was instrumental and included credits to ya. it's called Hydro-SMS

HydroAcoustics_broadcast_wb.jpg
author
Max12max made it! (author)2016-11-30

hey

author
Max12max made it! (author)2016-11-29

So I can actually see what your doing

author
Max12max made it! (author)2016-11-29

Take better pictures

author
Max12max made it! (author)2016-11-29

It rlly hard

author
Max12max made it! (author)2016-11-29

How u do dis

author
MrHenry1876. made it! (author)2016-10-02

/*

Morse Code Project

This code will loop through a string of characters and convert these to morse code.

It will blink two LED lights and play audio on a speaker.

*/

//***********************************************************************************//

// SENDING YOUR TEXT BELOW USING SPACE FOR EACH CHARACTER IN string To Morse Code //

//***********************************************************************************//

char stringToMorseCode[] = ''T Y E P E Y O U R T E X T H E R E ! ! !";

// Create variable to define the output pins

int led12 = 12; // blink an led on output 12

int led6 = 6; // blink an led on output 6

int audio8 = 8; // output audio on pin 8

int note = 900; // music note/pitch

/*

Set the speed of your morse code

Adjust the 'dotlen' length to speed up or slow down your morse code

(all of the other lengths are based on the dotlen)

Here are the ratios code elements:

Dash length = Dot length x 3

Pause between elements = Dot length

(pause between dots and dashes within the character)

Pause between characters = Dot length x 3

Pause between words = Dot length x 7

http://www.nu-ware.com/NuCode%20Help/index.html?m...

*/

int dotLen = 100; // length of the morse code 'dot'

int dashLen = dotLen * 3; // length of the morse code 'dash'

int elemPause = dotLen; // length of the pause between elements of a character

int Spaces = dotLen * 3; // length of the spaces between characters

int wordPause = dotLen * 7; // length of the pause between words

// the setup routine runs once when you press reset:

void setup() {

// initialize the digital pin as an output for LED lights.

pinMode(led12, OUTPUT);

pinMode(led6, OUTPUT);

}

// Create a loop of the letters/words you want to output in morse code (defined in string at top of code)

void loop()

{

// Loop through the string and get each character one at a time until the end is reached

for (int i = 0; i < sizeof(stringToMorseCode) - 1; i++)

{

// Get the character in the current position

char tmpChar = stringToMorseCode[i];

// Set the case to lower case

tmpChar = toLowerCase(tmpChar);

// Call the subroutine to get the morse code equivalent for this character

GetChar(tmpChar);

}

// At the end of the string long pause before looping and starting again

LightsOff(3000);

}

// DOT

void MorseDot()

{

digitalWrite(led12, HIGH); // turn the LED on

digitalWrite(led6, HIGH);

tone(audio8, note, dotLen); // start playing a tone

delay(dotLen); // hold in this position

}

// DASH

void MorseDash()

{

digitalWrite(led12, HIGH); // turn the LED on

digitalWrite(led6, HIGH);

tone(audio8, note, dashLen); // start playing a tone

delay(dashLen); // hold in this position

}

// Turn Off

void LightsOff(int delayTime)

{

digitalWrite(led12, LOW); // turn the LED off

digitalWrite(led6, LOW);

noTone(audio8); // stop playing a tone

delay(delayTime); // hold in this position

}

// *** Characters to Morse Code Conversion *** //

void GetChar(char tmpChar)

{

// Take the passed character and use a switch case to find the morse code for that character

switch (tmpChar) {

case 'a':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'b':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'c':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'd':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'e':

MorseDot();

LightsOff(elemPause);

break;

case 'f':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'g':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'h':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'i':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'j':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'k':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'l':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'm':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'n':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'o':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'p':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 'q':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'r':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 's':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case 't':

MorseDash();

LightsOff(elemPause);

break;

case 'u':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'v':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'w':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'x':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'y':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case 'z':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '0':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '1':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '2':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '3':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '4':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '5':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '6':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '7':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '8':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '9':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '.':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case ',':

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '?':

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '!':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '/':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '=':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '+':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '-':

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

break;

case '&':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

case '@':

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

MorseDash();

LightsOff(elemPause);

MorseDot();

LightsOff(elemPause);

break;

default:

// If a matching character was not found it will default to a blank space

LightsOff(Spaces);

}

}

/*

Unlicensed Software:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or

distribute this software, either in source code form or as a compiled

binary, for any purpose, commercial or non-commercial, and by any

means.

In jurisdictions that recognize copyright laws, the author or authors

of this software dedicate any and all copyright interest in the

software to the public domain. We make this dedication for the benefit

of the public at large and to the detriment of our heirs and

successors. We intend this dedication to be an overt act of

relinquishment in perpetuity of all present and future rights to this

software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,

EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR

OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,

ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR

OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to

*/

author
Lintang_Wisesa made it! (author)2016-04-01

Check my version, Android controlled ^_^ https://youtu.be/_eryK1NHz8Q

81. 2016 - Morse Blubuzter.jpg
author
rodrigonh made it! (author)2016-03-16

I didnt checked it all but it seems that code for 'd' is wrong

author
iqah.jamil made it! (author)2016-02-26

can i use usb powered speaker to replace mini speaker?

author
Chris Weatherford made it! (author)Chris Weatherford2016-03-04

I'm not aware of any way to run USB devices off an Arduino. You would probably have to use a shield which attaches to the Arduino. I did a quick search on this but don't see any answers right away. With that said you could probably recreate this project on a Raspberry Pi. The setup would be different but the general idea is there. The RPi can accept USB devices. Good luck! Let us all know how it goes.

author
dsrowe made it! (author)2015-05-28

Ok Chris and Community,

this is my first attempt at Arduino and programming. I'm getting errors in the code (see below). I tried changing /adding tokens, but that did not work. I'm a novice and need help. I don't understand your step 4 upload code and change the string to morse code. I cut and paste from a plain text file. Please explain in more simple words.

morse_code_052515a.ino: In function 'void loop()':
morse_code_052515a:41: error: a function-definition is not allowed here before '{' token
morse_code_052515a:48: error: a function-definition is not allowed here before '{' token
morse_code_052515a:349: error: expected '}' at end of input
a function-definition is not allowed here before '{' token

Thanks for any assistance.

DR owe

author
raulcorde made it! (author)2015-04-26

Done!

I've made another version in void loop() to send strings by Serial Monitor:

void loop(){

if (Serial.available() > 0) {

char i = Serial.read();

char tmpChar = i;

tmpChar = toLowerCase(tmpChar);

GetChar(tmpChar);

}

}

Good job, Chris!

la foto 18.35.07.JPG
author
DwayneG made it! (author)2015-02-21

Made this for the second project with Instructables. We changed the length between characters by adding a delay(500) before the break of each character and corrected the letter 'd'. D is Dash, Dot, Dot. Fairly fun project. Thank you.

IMG_2935.JPG
author
Makedo made it! (author)2014-11-25

The boy scouts had brought back the signalling merit badge back for their 100th anniversary . to learn the code just use an old typing drill that uses all the letters of the alphabet " the quick brown fox jumps over the lazy dogs back" translate to code and just practice and memorize it and you will have it down in about a week. I took 10 boys from different ages and abilities in 1 month to earn the badge. converting everything into code and back on a computer is easy. doing it for real is satisfying. you can even use short cuts to speed up communication just like using texting short cuts.

author
iam_maker_leo made it! (author)2014-11-19

Nice project...

And it can be upgrage to add ethernet shield and send a message from outside and/or control it via internet.

author
espdp2 made it! (author)2014-11-16

Very nice. Now to make several of them to send and receive, encode and decode. What's the range of XBee again?

I've tried learning Morse and American Sign Language. Too many small children, not enough time... ;-)

author
thassaj made it! (author)2014-11-16

What would be cool (in a slightly pointless but amusing way) would be to build a controller that moves a hand and sends CW by operating a manual "straight key" :-)

author
void_main made it! (author)2014-11-13

Nice!
Your code is 300+ lines (not counting license).
Challenge: how to write it in less than 150 while improving code readability?

author
NoseyNick made it! (author)NoseyNick2014-11-14

I've written a similar program myself. I put the (equivalent of) LightsOff(elemPause) INTO the MorseDot() and MorseDash(), which I called dit() and dah(), so my case 'c':
can be just dah(); dit(); dah(); dit(); break;

Then having ALREADY HAD one dotlen or elemPause of silence, take one off of each of...
Spaces = dotLen * 2; wordPause = dotLen * 6;

author
void_main made it! (author)void_main2014-11-14

Good thinking.

This will definitely shorten the number of lines but... it is not going to improve code readability. You still are going to have the same issue with understanding that 'dah(); dit(); dah(); dit()' is just '-.-.'

Can you store each letter as sequence of dashes and dots and then just 'play' them?

Hint: start with writing a function play() which takes string like '-.-.'

author
NoseyNick made it! (author)NoseyNick2014-11-15

True, you can, BUT strings on Arduino take up valuable RAM, unless you muck with PROGMEM and prog_char and stuff, which is going to be really ugly again. Admittedly if your only strings are a morse copy of the alphabet, you'll be fine. :-/

author
clem16 made it! (author)2014-11-13

Just a FYI, The Morse Code requirement for ham licence has been dropped.

author
dewmik made it! (author)dewmik2014-11-13

CW is still fun though. This is a great idea

author
clem16 made it! (author)clem162014-11-15

I know I have my HAM and CW is fun!

author
Chris Weatherford made it! (author)2014-11-13

Thanks for all the great comments and suggestions! I'm not much of a programmer so I will leave this to the community to improve. I could reduce the number of lines but I added a lot of extra just to make it easier for everyone to understand. I was reading a little about libraries and it sounds like I can probably move the morse code translation section all into a separate support file if I understand this correctly. That will have to be a future improvement.

For the next version I was thinking it would be cool to have two and each would have a light sensor to record and translate the dits and dots (thanks Liam) into words. Hooking up a keyboard is a great idea too Jack. Then you could just type and transmit whatever you wanted on the fly.

So many possibilities....so little time!!!

Chris

author
Liamthe1st made it! (author)2014-11-13

Try saying SOS in dots and dashes Then in dits and Dahs

author
Liamthe1st made it! (author)2014-11-13

Dits and Dahs Is the correct way to describe morse it gives you the correct cadence

author
Sock Puppet made it! (author)2014-11-13

Great stuff!

author
econjack made it! (author)2014-11-13

Fun Instructable! I got my ham radio license over 60 years ago and still enjoy Morse code. If void_main wants to see a shorter version, have him check my book, Arduino Projects for Amateur Radio. There are projects for reading Morse code, plus two for sending it, including using an old PS2 keyboard instead of a key.

Jack Purdum, W8TEE

author
RobertWa made it! (author)2014-11-13

I would really like to see you get the old Morse Code pad working! This would be a great way to show it in action. Maybe be able to read in actual dots and dashes from the board. Show on a LCD screen what the person entered! Would be cool for a museum demo.

author
t.rohner made it! (author)2014-11-13

Nice instructable, but who decodes it?

I learned morse at around 12 years old. At that time, i was able to listen at speed 60.

When i made my Ham license at 17, i made it without morse, because i didn't practise these 5 years in between. I would have to start from the beginning again...

author
MsSweetSatisfaction made it! (author)2014-11-11

That's an awesome combination of old and new, it's really striking!

About This Instructable

73,891views

318favorites

More by Chris Weatherford:LED Glowing Floating Picture FrameDisable The Kill Switch on a Riding MowerFiretruck Costume
Add instructable to: