Code Monkey home page Code Monkey logo

morse_code's Introduction

morse_code

Morse Code library for Arduino.

Turns digital pin on and off with morse code timing.

Tested with Mega 2560, two wire laser module, and Neo7 GPS with 9600 baud.

Usage:

EX1. Terse. Change speed and device pin.
  • #include "morse_code.h"
  • morseCode mc;
  • mc.pwmPin(11); // default is 10
  • mc.defineUnit(150); // default is 10
  • ms.messageToEncode("SOME MESSAGE A-Z 0-9 -9.0"); // Not Case Sensitive
  • mc.playMessage();

EX2. Add all elements in constructor

  • #include "morse_code.h"
  • morseCode mc("SOME MESSAGE", 11, 150);
  • mc.playMessage();

EX1. Default speed 250 with GPS SOS, Change pin.

  • #include "morse_code.h"
  • morseCode mc;
  • mc.pwmPin(11); // default is 10
  • mc.playGpsSos("MESSAGE TO INCLUDE"); // SOS LAT 9.9 LON -9.9 [MESSAGE] AR

Morse Codes are kept in global array: morseCodes[ ][ ] found in morse_code.cpp

Contains upper case letters A-Z, numbers 0-9 and also includes (.) period, and, (-) minus sign, for GPS Coordinates.

If you add elements to the array, be sure to add their alphanumeric digit to the Alphabet string in _getCode(); morse_code.cpp

  • #define CODES_CNT 38

Example code can be used with a laser pointer with (+) wire in digital pin 10 (by default) and the (-) wire in ground. The code will flash laser dots and dashes with the proper morse code durations.

The same code can be used with a passive buzzer or any other device if attached to pin 10 and ground. Any device attached to the default, or, user defined pin will recieve HIGH (on) and LOW (off) output.

Method playGpsSos(msg) will find your gps coordinates and play a message with the text: "SOS LAT 99.99 LON 99.99 [msg] AR"

Spacing and length of the signals are calculated from one unit.

  • A dot is equal to one unit.
  • A dash is equal to three units.
  • The space between the signals forming the same letter is equal to one unit.
  • The space between two letters is equal to three units.
  • The space between two words is equal to seven units.

These settings can be found in morse_code.h

  • // In milliseconds 250 = 1/4 of a second.
  • #define DEFAULT_UNIT 250
  • // Digital pin for device.
  • // change here or constructor.
  • #define DEFAULT_DEV 10
  • // Change your GPS Baud here.
  • #define GPS_BAUD 9600
  • // For GPS Mega 2560 uses 19, 18 RX, TX Uno use 4,3
  • #define RX 19
#define TX 18

#define _ss Serial1 // Comment for Uno.

If using Uno, or SoftwareSerial, be sure to uncomment the following line in morse_code.cpp

// SoftwareSerial _ss(RX, TX);

Uncomment the following line in morse_code.h

// #include "SoftwareSerial.h"

morse_code's People

Contributors

jwilke101 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.