Skip to content

markfickett/arduinomorse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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