From charlesreid1

This page covers the use of a morse code library to operate a blinking LED on the Arduino Micro.

Morse Code on the Arduino

First, let's talk about how to get some morse code libraries on the Arduino.

Morse Code Arduino

We basically have two options:

I'll show an example of using both, so you can get an idea of the advantages/disadvantages of different libraries. Morse code is a good example of how a relatively simple task can quickly become befuddling to implement, but how there are many tasks that already have libraries.

The Arduinomorse Library

To use the Arudinomorse library, see the Arduinomorse Library and Arduino Installing Libraries for installation instructions for getting libraries into the Arduino Development Environment.

The Morse Library

To use the Morse library, see the Morse Library page for installation.



Arduino Sketch Code

The following sketches show how to implement a simple blink circuit with morse code.

Arduinomorse Blink

Now we can rewrite our sketch to use the arduinomorse library. NOTE THAT THE MESSAGE WE SEND MUST BE LOWERCASE:

#define PIN_STATUS 12
#include <morse.h>
LEDMorseSender sender(PIN_STATUS);
//SpeakerMorseSender sender(PIN_STATUS);

void setup() {
    sender.setup();
    sender.setWPM(20);
    sender.setMessage(String("v v v de kc7dbu ar"));
    sender.startSending();
}
void loop() {
    sender.continueSending();
}

How does this bad boy work? Well, the morse library contains encodings of letters into dots and dashes. These dots and dashes are then encoded into voltage signals that are dits or dashes. When the voltage is applied, the LED lights up.

Morse Blink

The morse library works differently, by giving the user finer-grained control at the character-by-character level, but it follows the same basic idea.

Morse morse();
morse.send(s);
morse.send(o);
morse.send(s);