RaspberryPi/Morse Code
From charlesreid1
This page describes how to send code in Python from a Raspberry Pi, using the michael-morse library. Code is on GitHub here: https://github.com/charlesreid1/michael-morse
Contents
Overview
How It Works
The michael-morse library basically creates a queue of activities. It translates an ascii message into morse code, and morse code into a series of scheduled on/off switches.
These switches are tied to actions that can be either hardware- or software-based.
Details
The Code
The code is on GitHub: https://github.com/charlesreid1/michael-morse
Example
There is a simple example included in the GitHub repository: https://github.com/charlesreid1/michael-morse The example shows you how to control an LED on the Raspberry Pi GPIO by integrating it with the Morse library.
The procedure looks like this:
- Prepare the GPIO to be controlled by the Raspberry Pi
- Define the on/off functions controlled by the morse code keyer
- Make a Michael Morse object
- Fire off your message
# Use michael-morse to make an LED blink using Raspberry Pi GPIO.
# -----------------------
# RPi stuff
try:
import RPi.GPIO as GPIO
except RuntimeError:
print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")
# get ready to use gpio from pi
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
# use channel 15, i.e., P22
channel = 16
# gpio is used for output
GPIO.setup(channel, GPIO.OUT)
def LED_on():
GPIO.output(channel,GPIO.HIGH)
def LED_off():
GPIO.output(channel,GPIO.LOW)
# -----------------------
from MichaelMorse import MichaelMorse
m = MichaelMorse(15,on=LED_on,off=LED_off)
m.send("hello world de kc7dbu")
The Final Result
The Who What Why And All That
Why michael-morse?
What makes it different? This morse code library is aimed at use with the Raspberry Pi, so applications for using morse code include both circuitry (controlling the GPIO pin voltages) and non-circuitry (performing tasks or subroutines). Most of the other libraries I'd found were aimed at one or the other.
Who's Michael Morse?
The name of the library is an homage to Michael Morse, outfielder and designated hitter on the 2014 San Francisco Giants World Series team.