Arduino Morse Code Flaher

74,469

83

25

Introduction: Arduino Morse Code Flaher

I am a big fan of programming but I like to keep it down to 555 timer but when it comes to complex functions like flashing a LED in a certain pattern programming is necessary.One day while surfing through the I came across something known as Morse code.I decided to read it and found it totally awesome.I tried to make it with an arduino and I was successful in doing so. And now here that project explaining what I did.This is a low cost fun to do project suitable for beginners ;it also requires minimal parts.

This instructable will explain how to create the circuit ,making a shield for the arduino,making some changes,displaying custom messages and how to install the Morse code library.

This instructable is a entry in the arduino contest so if you like it please vote.

Here is a short video of it in action:

The first message that it displays is the SOS the second that it displays is HI and the third message that it displays is HELLOW.You can see the LED blink for three or four times in between the message this means that a new code has been uploaded and a new message is been displayed.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Morse Code

Morse code is a method of transmitting textual information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment. The International Morse Code encodes the ISO basic Latin alphabet, some extra Latin letters, the Arabic numerals and a small set of punctuation and procedural signals as standardized sequences of short and long signals called "dots" and "dashes" respectively, or "dis" and "dahs". Because many non-English natural languages use more than the 26 Roman letters, extensions to the Morse alphabet exist for those languages.
Each character (letter or numeral) is represented by a unique sequence of dots and dashes. The duration of a dash is three times the duration of a dot. Each dot or dash is followed by a short silence, equal to the dot duration. The letters of a word are separated by a space equal to three dots (one dash), and two words are separated by a space equal to seven dots. The dot duration is the basic unit of time measurement in code transmission.In the picture you can see the Morse code for each alphabet and number.

Step 2: Parts & Tools

Parts-
~ 1 x LED (color optional) - Sparkfun.com
~ Arduino Board - Sparkfun.com
~ 330 Ohm Resistor - Sparkfun.com

Tools-
~ The arduino programming Environment - Arduino.cc
~ USB Cable A-B - Sparkfun.com
~ Soldering Iron - Sparkfun.com
~ Solder Wire - Sparkfun.com

The price will be about 0.60 \$ assuming that you have a arduino and all the tools and if not it will be about 47.95 \$ (Quiet expensive)

Step 3: Built the Circuit

We have collected all the parts we need now lets make the circuit.The circuit is pretty straight forward (it could also be the simplest circuit you have ever seen) connect the longer lead of the LED (i.e the positive terminal) to digital pin13 and the shorter lead of the LED (i.e the negative terminal) to the gnd pin of the arduino(located besides the digital pin13) you need not connect a resistor as there is already a resistor connected to the digital pin13 or you can use the LED attached to digital pin 13 on the board itself. See the last picture for the fritzing diagram.

Step 4: The Library

Now having built the circuit its time to upload some code to our arduino but besides that I have also included the Morse code library (the reason why some of you are reading this).Now lets start up and install our library (fun eh) and upload some code.

To install your library first, make a Morse directory inside of the libraries sub-directory of your sketchbook directory. Copy or move the Morse.h and Morse.cpp files into that directory. Now launch the Arduino environment. If you open the Sketch > Import Library menu, you should see Morse inside. The library will be compiled with sketches that use it. If the library doesn't seem to build, make sure that the files really end in .cpp and .h (with no extra .pde or .txt extension, for example).

I have included a downloadable folder which you have to just paste in your libraries folder.

Screenshots are also included so that you can easily install the library.The location of the arduino folder in your computer maybe different.

The example codes are included in the library just open file>examples>Morse and choose your desired message that you want to display(see the last screenshot).If you want to display any other message other than that in the library feel free to ask or just make it yourself.

Step 5: Displaying Custom Message

We can display a custom message on the LED using the Morse code library (The library makes it easy to make your own messages).Refer to picture on step two to see the morse code for every alphabet and number on the basis of that type "morse.dot()."to display a dot on the LED and type "morse.dash();" to display a dash on the LED.To make your own code follow this format:

#include <Morse.h>

Morse morse(13);

void setup()
{
}

void loop()
{

}

Enter your code between the curly brackets after the void loop()

We will consider the example of flashing SOS the letter S consists of three dots so we write "morse.dot();" for three times The letter 0 consists of three dashes so we write "morse.dash();" for three times again the letter S has 3 dots so we write "morse.dot();" for three times and everythings done and your code for flashing SOS in morse code is ready.

#include <Morse.h>

Morse morse(13);

void setup()
{
}

void loop()
{
morse.dot(); morse.dot(); morse.dot(); // The letter S consists of three dots
morse.dash(); morse.dash(); morse.dash(); // The letter O consists of three dashes
morse.dot(); morse.dot(); morse.dot(); // The letter S consists of three dots
delay(3000);
}

The library itself contains four examples
1. SOS
2. HELLOW
3. HI
4. BOT1398

To open the examples open file>examples>Morse and choose your desired message.In the video on the first step you can see three different messages been flashed.

Step 6: Testing

To test your circuit plug the arduino into the USB port and program your arduino for any message(Eg-SOS) you can use the USB port for powering your arduino or you can use a 3.5mm jack to power it.(NOTE: the voltage from the 3.5 mm jack should not exceed 9v DC) after powering the arduino the LED at digital pin13 should start blinking in different patterns.A short blink means its a dot and a long blink means a dash.We take the example of SOS the message SOS in morse is something like this- dot dot dot dash dash dash dot dot dot.So the LED will give three short blinks then three long blinks and again three short blinks.See the video on step one and you will get the idea.You can also see the video directly on youtube.

Step 7: All Done!

Hope this project inspires further experimentation. The Arduino board is incredibly versatile,cheap, and accessible to all hobbyists . This is just one of many simple projects which can be constructed using the arduino. Keep pondering!. Don't forget to follow mores comming up!!. For any queries leave a comment me or send me a PM or mail it to me at r1398ohit@gmail.com

Participated in the
Arduino Challenge

112 4.6K
36 10K
768 45K

25 Discussions

Here is my version (for situations when conservation of memory IS an issue). Transmits a stored message over and over again by simply flashing the built in LED on Arduino Nano or Digispark.
I have used a struct to encode dash-dot sequence for each letter in a bit field and the number of symbols for each letter:
struct mc {
unsigned char dd;
unsigned char len;
};
Using something like
struct mc {
unsigned int dd:6;
unsigned int len:3;
};
performs the same, using exactly the same amount of memory (because we need 6+3=9 bits for each letter) and the produced code is even slightly longer.
The Morse equivalents of all the letters are stored in an array
const struct mc mrs[] = { // right to left bit encoded, 1=-; 0=. , only len rightmost bits valid
...
/* A = ".-" */ { 0b000010, 2},
/* B = "-..." */ { 0b000001, 4},
/* C = "-.-." */ { 0b000101, 4},
...
Here is the sketch file. Feel free to use it or comment.

i keep getting this error

In file included from sketch_sep22a.ino:1:

C:\Users\cc-electronics\Desktop\Arduino\libraries\Morse/Morse.h:10:22: error: WProgram.h: No such file or directory

This is because the library is made for old IDE. You should go to the library path (C:\Users\cc-electronics\Desktop\Arduino\libraries\Morse) and replace in Morse.h and Morse.cpp "WProgram.h" with "Arduino.h"

great job

i created a site to translate text to morse so it is just copy paste

http://blueeye.dk/?page_id=39 and scroll to the bottom

Check out my blog post at http://jamestav.blogspot.com/2013/03/arduino.html?spref=bl. I made a morse code device that uses the serial port in the Arduino IDE. Feel free to use the code and mash it up with this code

you need to change the Wprogram.h include in the CPP and H file to Arduino.h

Cool. Never knew you could make custom libraries! I made a "hello" message manually:
```/*This program has a buzzer hooked up to Pin 11.
(My buzzer fit right between GRD and 11, so I used that.)*/

int buzzerPin=11;

void setup()
{
pinMode(buzzerPin, OUTPUT);
}

void loop()
{
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(1000);                 //....(H)
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(1000);               //.(E)
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(500);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(1000);                  //.-..(L)
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(500);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(1000);                 //.-..(L)
digitalWrite(buzzerPin, HIGH);
delay(500);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(500);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(500);
digitalWrite(buzzerPin, LOW);
delay(5000);               //---(H)
}

```

To do:
Right-Click,
Copy as HTML
IN THE EMBED VIDEO DIALOG:
Paste

Typing the code up like that seems like a lot of work. I made a morse code translator where you type out the message on the serial monitor send it to the arduino where it translates the message to morse code and an led flashes the message.

see here code.

Nice job! Now, if someone could create a tone detector with an arduino, A program I adapted from an old MBASIC program, would go the other direction! (convert Morse code received off a radio, to ASCII text.)

I gave it in BASIC for PICAXE... they are very cheap chips.

https://www.instructables.com/id/Morse-Code-Magic-An-Algorithm/

I've been to busy to convert to an Arduino lib, but should be straightforward.

BTW, there are a number of Magic Morse posts on Instructables... one even uses the algorithm in "reverse" to send the temperature as a number.

- Ray

Nice Project, but i have a few questions:
When I paste the SOS code from step 5 and I verify it, it says:

In file included from sketch_mar06a.cpp:1:
C:\Users\Doede\Desktop\Arduino\arduino-1.0\libraries\Morse/Morse.h:10:22: error: WProgram.h: No such file or directory

I have downloaded the .zip and placed it where I have to.
What can I do?

You are using arduino 0.1 I also had problems with it switch back 0022 or 0023 and you will be fine

Thanks, I downloaded both 0022 and 0023. This time, when verifying, there where no errors, but when I tried to upload it gave me this message on both versions:

Binary sketch size: 1362 bytes (of a 32256 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

(btw, this is my first arduino project, thats why I don't get it ;) )

I suspect you havent installed the drivers so do it a step by step screenshot's can be found be here.I had the same error when I tried my first arduino program but then I realized I had to install the drivers.!