Morse Code Generator
- - - - - . - . . . . . - . - . - - - - . . . - - . . - . . . - . . - - - - - . - . . - . - . -
Overview
This project generates Morse code from input text. The input is entered in console using the keyboard, and read through the USB virtual COM port. The generated code is displayed on the console, and played on the speaker and the mbed built-in LED. The Morse code generator in this project follows the International Morse code Recommendation ITU-R M.1677-1.
Components
Hardware
- uLCD-144-G2
128 by 128 Color Smart LCD with serial interface and SD card slot
- Speaker (including a driver transistor and a 220-1k resistor)
- Pushbuttons (6)
Software
- uLCD-144-G2 Library
Import library4DGL-uLCD-SE
Fork of 4DGL lib for uLCD-144-G2. Different command values needed. See https://mbed.org/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/ for instructions and demo code.
- Speaker using PWM Library
Import programspeaker_demo_PWM
Demo for new class to play a note on a speaker using a PWM output See http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/
- Pin Detect Library
Import libraryPinDetect
InterruptIn style DigitalIn debounced with callbacks for pin state change and pin state hold.
- USB Virtual Serial Port Library
Import library
Public Member Functions
Serial (PinName tx, PinName rx, const char *name=NULL) Create a Serial port, connected to the specified transmit and receive pins.
void baud (int baudrate) Set the baud rate of the serial port.
void format (int bits=8, Parity parity=SerialBase::None, int stop_bits=1) Set the transmission format used by the serial port.
int readable () Determine if there is a character available to read.
int writeable () Determine if there is space available to write a character.
void attach (void(*fptr)(void), IrqType type=RxIrq) Attach a function to call whenever a serial interrupt is generated.
template<typename T > void attach (T *tptr, void(T::*mptr)(void), IrqType type=RxIrq) Attach a member function to call whenever a serial interrupt is generated.
void send_break () Generate a break condition on the serial line.
void set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC) Set the flow control type on the serial port.
- Terminal Application
- TeraTerm was used for this project.
Note
The mbed serial port works by default on Mac and Linux, but Windows needs an additional driver. Download the driver from the instructions here: http://mbed.org/handbook/Windows-serial-configuration
Connections
uLCD:
mbed | uLCD Header | uLCD Cable |
---|---|---|
VU | 5V | 5V |
Gnd | Gnd | Gnd |
p28 (TX) | RX | TX |
p27 (RX) | TX | RX |
p29 | Reset | Reset |
Speaker:
mbed | Speaker |
---|---|
p26 (PwmOut) | Resistor |
Pushbuttons (6):
mbed | Pushbutton # |
---|---|
p19 | #1 |
p20 | #2 |
p21 | #3 |
p22 | #4 |
p23 | #5 |
p24 | #6 |
Gnd | All |
Note
All pushbutton connections are set up to use an internal Pull-up mode, so the external resistor to Vcc is not necessary.
Demo
Image of the Set-up:
Video demo of "Hello world" - console capture:
The Morse code playback on the console is in sync with the LED and speaker.
Video demo of "Hello world":
Video demo of playback controls:
Project Code
Import programMorseCode
Generate Morse code using console text input and output to LED and speaker.
Future Work
- Implement Q code
- Implement Morse code abbreviations
- Implement Prosigns
References
“International Morse code Recommendation ITU-R M.1677-1”. itu.int. International Telecommunication Union. October 2009. http://www.itu.int/rec/R-REC-M.1677-1-200910-I/
Please log in to post comments.