From charlesreid1

(Redirected from Morse Library)

This is a little more information on the W5OBM Morse library, from the Arduino Ham Radio book.

http://www.w5obm.us/Arduino/index.html

Installing

Download

To install the W5OBM Morse library, download the directory containing the C code for the Morse library (link to the code).

Making a Zip File

Create a zip file from this directory, which will be called Morse.zip

Morse.zip will contain a folder called Morse/

The folder Morse will contain a file called Morse.h

Loading Library in Arduino

Now you can load the library into Arduino using the zip file you've just created.

Open the Arduino Development Environment, and pick Sketch > Include Library > Add .ZIP Library

Arduinomorse1.png

Navigate to the zip file Morse.zip and pick it. The menu and window should close.

Using the Library in Arduino

When you re-open the Sketch > Include Library menu, you should see the library you added at the very bottom.


Using

Picking the Pin

When using the Morse Library, you have to pick which pin you're using. Make sure you pick a pin where pulse width modulation (PWM) is enabled. The Morse library uses PWM to send the sound signal through the speaker, which makes the sound less harsh and annoying. But it means you have to make sure and use a PWM enabled pin. On the Arudino Micro and Arduino Leonardo, these pins are 3, 5, 9, 10, 11, and 13 (as listed here). Check with the manufacturer for information if it isn't indicated on the board itself.

Morse Code Beep Circuit

See the Morse Code Beep Arduino Micro page for a simple circuit using the Arduino Micro to send out morse code beeps.

Example Sketch

There is an example sketch included with the Morse library, given below. It shows how to send morse code in two ways: first, by sending a string. Second, by sending characters representing specific letters. Here is the example:

// Author Erik Linder
// Released 2011 under GNU GPLv3
//
// Usage: morse( <pin number>, <speed WPM>, <1=beep, 0=PTT> )
//        sendmsg( "<text-to-send>" )
//

#include <Morse.h>

// Uncomment to beep a speaker at pin 9
Morse morse(9, 12, 1);

void setup()
{
  // Nothing here for the Morse lib
}

void loop()
{
  morse.sendmsg("HELLO WORLD!");
  delay (2000);
  morse.send(83);
  morse.send(77);
  morse.send(48);
  morse.send(82);
  morse.send(86);
  morse.send(86);
  delay (2000);
}