Skip to content

PradeepaRW/morse-communicator-avr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Morse Communicator - AVR C Project

A robust, bidirectional Morse code terminal built with AVR C programming for Arduino Uno. This project implements both encoding (text to Morse) and decoding (Morse to text) capabilities with real-time LED and buzzer feedback.

๐ŸŽฏ Project Overview

This Morse Communicator was developed for the CO321 Embedded Systems course at the University of Peradeniya. It features:

  • Encoding Mode: Convert text input to Morse code with LED/buzzer output
  • Decoding Mode: Convert button presses to decoded text on LCD
  • Automatic Mode Switching: Alternates between encoding/decoding every 5 seconds
  • Real-time Feedback: LED and buzzer provide visual/audio Morse code output
  • Non-blocking Design: Uses timer interrupts instead of system delays

๐Ÿ› ๏ธ Hardware Requirements

Components

  • Arduino Uno (ATmega328P)
  • 16x2 LCD Display (HD44780 compatible)
  • Push Button
  • LED (with 220ฮฉ resistor)
  • Piezo Buzzer
  • Breadboard
  • Jumper Cables
  • 10kฮฉ Resistor (for button pull-up)

Pin Connections

LCD Display:
- Pin 1 (VSS) โ†’ GND
- Pin 2 (VDD) โ†’ 5V
- Pin 3 (V0) โ†’ Potentiometer (contrast)
- Pin 4 (RS) โ†’ Arduino A0
- Pin 5 (RW) โ†’ Arduino A1
- Pin 6 (E) โ†’ Arduino A2
- Pin 11 (D4) โ†’ Arduino A3
- Pin 12 (D5) โ†’ Arduino A4
- Pin 13 (D6) โ†’ Arduino A5
- Pin 14 (D7) โ†’ Arduino D7
- Pin 15 (A) โ†’ 5V (backlight)
- Pin 16 (K) โ†’ GND (backlight)

Button:
- Terminal 1 โ†’ Arduino D2
- Terminal 2 โ†’ GND
- 10kฮฉ Resistor โ†’ D2 to 5V

LED:
- Anode โ†’ 220ฮฉ Resistor โ†’ Arduino D9
- Cathode โ†’ GND

Buzzer:
- Positive โ†’ Arduino D10
- Negative โ†’ GND

๐Ÿ“ Project Structure

โ”œโ”€โ”€ include/                     # Header files
โ”‚   โ”œโ”€โ”€ morse_config.h          # Pin definitions and constants
โ”‚   โ”œโ”€โ”€ lcd_driver.h            # LCD interface functions
โ”‚   โ”œโ”€โ”€ serial_comm.h           # UART communication
โ”‚   โ”œโ”€โ”€ morse_encoder.h         # Morse encoding functions
โ”‚   โ””โ”€โ”€ morse_decoder.h         # Morse decoding functions
โ”œโ”€โ”€ src/                        # Source files
โ”‚   โ”œโ”€โ”€ main.c                  # Main program and state machine
โ”‚   โ”œโ”€โ”€ system_utils.c          # Hardware initialization
โ”‚   โ”œโ”€โ”€ lcd_driver.c            # LCD driver implementation
โ”‚   โ”œโ”€โ”€ serial_comm.c           # UART implementation
โ”‚   โ”œโ”€โ”€ morse_encoder.c         # Morse encoding logic
โ”‚   โ”œโ”€โ”€ morse_decoder.c         # Morse decoding logic
โ”‚   โ”œโ”€โ”€ lcd_test.c              # LCD component test
โ”‚   โ”œโ”€โ”€ button_test.c           # Button component test
โ”‚   โ”œโ”€โ”€ led_test.c              # LED component test
โ”‚   โ”œโ”€โ”€ buzzer_test.c           # Buzzer component test
โ”‚   โ””โ”€โ”€ serial_test.c           # Serial communication test
โ”œโ”€โ”€ docs/                       # Documentation
โ”‚   โ”œโ”€โ”€ hardware_setup.md       # Detailed wiring instructions
โ”‚   โ”œโ”€โ”€ lcd_troubleshooting.md  # LCD troubleshooting guide
โ”‚   โ””โ”€โ”€ project_report.md       # Project report template
โ”œโ”€โ”€ Makefile                    # Build configuration
โ””โ”€โ”€ README.md                   # This file

๐Ÿ”ง Building and Uploading

Prerequisites

  • AVR-GCC toolchain
  • AVRDUDE
  • Make

Build Commands

# Build main project
make all

# Build individual component tests
make lcd-test
make button-test
make led-test
make buzzer-test
make serial-test

# Upload to Arduino
make upload

# Upload individual tests
make upload-lcd
make upload-button
make upload-led
make upload-buzzer
make upload-serial

# Clean build files
make clean

# Show help
make help

๐Ÿงช Testing

Individual Component Tests

Each component can be tested independently:

  1. LCD Test: make upload-lcd

    • Displays text patterns, scrolling, special characters
  2. Button Test: make upload-button

    • Tests button press/release detection and counting
  3. LED Test: make upload-led

    • Tests LED blinking patterns and SOS sequence
  4. Buzzer Test: make upload-buzzer

    • Tests buzzer beeping patterns and SOS sequence
  5. Serial Test: make upload-serial

    • Tests UART communication with echo functionality

Main Project Testing

  1. Upload main project: make upload
  2. Open Serial Monitor (9600 baud)
  3. Test encoding mode: Type characters (A-Z, 0-9)
  4. Test decoding mode: Press button for dots/dashes
  5. Verify mode switching: Automatic 5-second alternation

๐ŸŽฎ Usage

Encoding Mode

  • LCD displays: "Encoding Mode" โ†’ "Send via serial"
  • Type characters via Serial Monitor (9600 baud)
  • LED and buzzer output Morse code patterns
  • Supported characters: A-Z, 0-9

Decoding Mode

  • LCD displays: "Decoding Mode" โ†’ "Press button"
  • Press button for dots (short press) and dashes (long press)
  • LCD shows decoded characters
  • End message with AR sequence (ยท โˆ’ ยท โˆ’ ยท)

Morse Code Timing

  • Dot duration: 100ms
  • Dash duration: 300ms (3x dot)
  • Symbol gap: 100ms
  • Letter gap: 300ms
  • Word gap: 700ms

๐Ÿ” Key Features

Non-blocking Design

  • Uses timer interrupts for timing
  • No system delays (_delay_ms())
  • Responsive to user input

State Machine Architecture

  • Clean separation between encoding/decoding modes
  • Automatic state transitions
  • Robust error handling

Component Isolation

  • Individual test programs for each component
  • Easy debugging and troubleshooting
  • Modular code structure

๐Ÿ› Troubleshooting

Common Issues

  1. LCD not displaying: Check power connections and contrast
  2. Button not responding: Verify wiring and pull-up resistor
  3. LED not lighting: Check resistor value and orientation
  4. Buzzer not working: Verify power connections
  5. Serial not working: Check baud rate (9600)

Testing Strategy

  1. Test each component individually first
  2. Verify hardware connections
  3. Check power supply
  4. Use multimeter for continuity testing

๐Ÿ“Š Project Statistics

  • Code size: ~3KB (2750 bytes)
  • Supported characters: 36 (A-Z, 0-9)
  • Modes: 2 (Encoding/Decoding)
  • Components: 5 (LCD, Button, LED, Buzzer, Serial)
  • Test programs: 5 individual component tests

๐ŸŽ“ Academic Context

This project was developed for:

  • Course: CO321 Embedded Systems
  • Institution: University of Peradeniya
  • Department: Computer Engineering
  • Semester: 8
  • Deadline: August 1st, 2025

๐Ÿ“ License

This project is developed for educational purposes as part of the CO321 Embedded Systems course.

๐Ÿค Contributing

This is an academic project, but suggestions and improvements are welcome through issues and pull requests.

๐Ÿ“ž Support

For questions or issues related to this project:

  1. Check the troubleshooting guides in the docs/ folder
  2. Review the individual component tests
  3. Verify hardware connections
  4. Test components individually before running the main project

Built with โค๏ธ for Embedded Systems Education

About

A robust, bidirectional Morse code terminal built with AVR C programming for Arduino Uno

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors