A bare-metal embedded project that decodes Morse code input from physical buttons and outputs the decoded letter over UART serial — running on an STM32F103 "Blue Pill" microcontroller.
Built using libopencm3 — an open-source peripheral library for STM32.
- Hold PA0 (Start button) → LED on PC13 turns ON, session begins
- Tap PA1 (Morse button) → short tap = dot
., long tap = dash- - Release PA0 → LED turns OFF, input is decoded and printed over serial
Dot/dash threshold: 300ms — tap under 300ms is a dot, over is a dash.
| Pin | Function |
|---|---|
| PA0 | Start/Stop button |
| PA1 | Morse input button |
| PA9 | USART1 TX (serial out) |
| PC13 | Onboard LED |
Board: STM32F103C8T6 "Blue Pill"
Clock: 72MHz via external 8MHz HSE crystal + PLL
Serial: 9600 baud, 8N1
- ARM cross-compiler:
arm-none-eabi-gcc - libopencm3 (set up in parent directory)
make- ST-Link or similar flasher to upload to the board
make # compiles morse.c → morse.elf + morse.binFlash to board using ST-Link:
st-flash write morse.bin 0x8000000Or using OpenOCD:
openocd -f interface/stlink.cfg -f target/stm32f1x.cfg \
-c "program morse.elf verify reset exit"Connect to USART1 TX (PA9) with a USB-to-TTL adapter at 9600 baud.
Example output:
Morse Code Ready...
.- A
-... B
... S
The decoder supports all 26 letters (A–Z) plus space:
| Letter | Code | Letter | Code |
|---|---|---|---|
| A | .- |
N | -. |
| B | -... |
O | --- |
| C | -.-. |
P | .--. |
| D | -.. |
Q | --.- |
| E | . |
R | .-. |
| F | ..-. |
S | ... |
| G | --. |
T | - |
| H | .... |
U | ..- |
| I | .. |
V | ...- |
| J | .--- |
W | .-- |
| K | -.- |
X | -..- |
| L | .-.. |
Y | -.-- |
| M | -- |
Z | --.. |
Unknown patterns output ?.
morseCode/ ├── morse.c ← main source code ├── Makefile ← build config ├── morse.elf ← compiled binary with debug info ├── morse.bin ← raw binary for flashing ├── morse.map ← memory map ├── morse.o ← compiled object file └── morse.d ← dependency file
---
Dhanvi Vijaykumar