Skip to content

Arduino library for convinient Morse-code playing

License

Notifications You must be signed in to change notification settings

Igorello74/Morse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Morse

Arduino library for convinient Morse-code playing

Goals

The library is intended to easily play Morse code at a pin of Arduino. You can just type needed sentence (using dots and dashes) and it will be played with required speed. Also, the library allows debugging.

Methods

Constructor

Morse(byte pin, byte unit, MDebug debug = NONE);
  • byte pin — the pin to which the executing device is connected
  • byte unit — duration of one unit (see below) in ms (milliseconds)
  • MDebug debug — see below (Debugging)

Playing

There are two ways to set a morse sequence — with an array of MSymb or with a String.

Morse char Array notation String notation Duration in units
dot DO . or * 1
dash DA - 3
space between parts of one letter PS played automatically 1
space between letters LS space 3
space between words WS / 7

Whatever way you choose, you need to use the play function:

  • void play (MSymb ser[], byte num)
    • Comment: num is the number of characters presented (lenght of the array).
    • Possible sequence: MSymb sos[] = {DO, LS, DO, LS, DO, LS, DA, LS, DA, LS, DA, LS, DO, LS, DO, LS, DO};
  • void play (String &ser)
    • Possible sequence: String sos = "***---***";

As you see, it's much more convenient and easy to use the second way, so the array method can be called legacy.

setUnit

void setUnit(byte unit);

If you suddenly want to alter the unit duration after creating an instance, you can use the setUnit function, the unit of the unit (pardon for tautology) is milliseconds, as well.

As you have already seen, there is the debug variable in the constructor. It can take the following values:

Debug value Description
NONE no debugging used
LED pulses the built-in led according to the morse signal
SER sends messages into Serial in the Array notation (see above)
SERLED combines two previous modes

Examples

All examples are present in the examples/ folder.

Compatibility

This library has been tested with Arduino Uno and Nano. In addition, it's supposed to work with most of Arduino-like boards. The library successfully works in either Arduino IDE and PlatformIO. I recomend the last!

License

The library is published under the MIT License, for more details, see LICENSE.

Contact

Pull-requests and other contributing are welcome!

About

Arduino library for convinient Morse-code playing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages