Skip to content

markfickett/arduinomorse

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Morse Code Library for Arduino with Non-Blocking Sending

This is a library for generating and sending Morse code; particularly, via LED or speaker. Among myriad such libraries, its key feature is allowing Morse to be sent without blocking other processes, such as monitoring sensors.

Authorship and License

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License; it is written by Mark Fickett. (Do let me know if you find it interesting or useful! Or, should you find bugs, a report or a pull request would be welcome.)

Example

The library includes several examples; or see below. Briefly:

#define PIN_STATUS	13
LEDMorseSender sender(PIN_STATUS);
void setup() {
	sender.setup();
	sender.setMessage(String("73 de kb3jcy "));
	sender.startSending();
}
void loop() {
	sender.continueSending();
}

Or, in more detail:

// Morse will be sent on the built-in status LED on pin 13.
#define PIN_STATUS	13
// For example, a switch might be connected to pin 12.
#define PIN_SENSOR	12

#include <morse.h>

LEDMorseSender sender(PIN_STATUS);

void setup()
{
	// Set the pin as OUTPUT.
	sender.setup();
	// Set the message to be sent. (This may be set again at any point, as
	// may be speed (wpm) or, for SpeakerMorseSender, the tone frequency.)
	sender.setMessage(String("73 de kb3jcy "));

	// Other setup:
	pinMode(PIN_SENSOR, INPUT);
	digitalWrite(PIN_SENSOR, HIGH);
}

void loop()
{
	// Calling continueSending checks elapsed time and toggles the output
	// accordingly. It returns false if the entire message has been sent,
	// or if the sender is uninitialized.
	if (!sender.continueSending())
	{
		// Set the internal counters to the message's beginning.
		// Here, this results in repeating the message indefinitely.
		sender.startSending();
	}

	// Do arbitrary other work, so long as it takes significantly less time
	// than sending a Morse element.
	if (digitalRead(PIN_SENSOR) == LOW)
	{
		// ...
	}
}

Installation

See "Contributed Libraries" on arduino.cc Libraries reference. Briefly, place these files in a morse subdirectory in your sketchbook directory.

Character Support

The alphabet is supported (all input must be lowercase), as are numbers.

There is partial support for punctuation and (using symbolic constants which take uppercase alphabetic values) prosigns; all that is required for expanding support is entering definitions.

Motivation

This was written to be used for status output for a bicycle cyclocomputer project using the LilyPad Arduino, which produces multi-second Morse output while at the same time counting bicycle wheel revolutions.

About

Morse for Arduino, with Non-Blocking Sending

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages