Home > Projects > Development Board – Kits Projects > Arduino Lab 2 – Morse Code Generator

Arduino Lab 2 – Morse Code Generator

Summary of Arduino Lab 2 – Morse Code Generator


This lab demonstrates how to transmit the international Morse Code distress signal (S.O.S.) using an Arduino board and an LED. The project explores three coding variations: Bare-Bones, Commented, and Subroutine versions, all achieving identical results. By utilizing Pin 13's built-in LED or an external setup, users can simulate SOS signals through timed light pulses representing dots and dashes. This exercise highlights fundamental programming constructs while illustrating Morse Code's reliability in emergency communications.

Parts used in the Morse Code Generator:

  • Arduino Development Board (Duemilanove, Uno or Mega)
  • USB cable matching the Arduino board and computer
  • LED (any color)
  • Resistor (220 to 270 Ohms)

Introduction

An excerpt from OmniGlot.com about the origin of Morse Code:

Morse Code was invented by Samuel F. B. Morse (1791-1872), a painter and founder of the National Academy of Design. He conceived the basic idea of an electromagnetic telegraph in 1832, and produced the first working telegraph set in 1836. This made transmission possible over any distance. The first Morse Code message, “What hath God wrought?”, was sent from Washington to Baltimore.

Today experienced operators copy received text without the need to write as they receive, and when transmitting, can easily converse at 20 to 30 words per minute. Morse Code will always remain a viable means of providing highly reliable communications during difficult communications conditions.

Morse Code can be transmitted using sound or light, as sometimes happens between ships at sea. It is used in emergencies to transmit distress signals when no other form of communication is available. The standard international distress signal is dot-dot-dot dash-dash-dash dot-dot-dot (SOS)Arduino Lab 2 - Morse Code Generator

Description

This lab will use an LED to transmit the International Morse Code Distress Signal (S.O.S.). Here is what Morse Code looks like:

Parts Required

You will need the following to complete this Lab:

One Arduino Development Board (Duemilanove, Uno or Mega)

  • One USB cable that has connectors matching your Arduino board and your computer
  • One LED (any color)
  • One Resistor (220 to 270 Ohms)

Programming

The letters S.O.S. would be transmitted as three dots, then three dashes, then three dots. This is sometimes written in text as “dit-dit-dit, pause, dah-dah-dah, pause, dit-dit-dit” where dit represents dots or short transmissions and dah represents dashes or longer transmissions.

To help students see some of the different programming possibilities, this code will be shown in three versions or variations:

  1. The “Bare-Bones” version. This version will be about as short and simple as this code can get.
  2. The “With Comments” version. The same as “Bare-Bones” with many comments to explain what is happening, and
  3. The “Subroutine” version, where code for the dots and dashes is in a subroutine.

All three programs will perform exactly the same. The third version will illustrate the use of several programming constructs that are common for more experienced programmers.

Hookup

Here is the wiring diagram and schematic. Pin 13 is used on the Arduino because pin 13 is also hard-wired to the on-board LED on the development board. It is a small surface-mounted LED marked “L” and placed near pin 13.

The Bare-Bones Program

void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
for (int x = 1; x <= 3; x++)
{
digitalWrite(13, HIGH);
delay(150);
digitalWrite(13, LOW);
delay(100);
}Arduino Lab 2 - Morse Code Generator Schematicdelay(100);
for (int x = 1; x <= 3; x++)
{
digitalWrite(13, HIGH);
delay(450);
digitalWrite(13, LOW);
delay(100);
}
delay(100);
for (int x = 1; x <= 3; x++)
{digitalWrite(13, HIGH);
delay(150);
digitalWrite(13, LOW);
delay(100);}
delay(2000)}

Bare-Bones with Comments

At this point, you could enter the program above, or cut and paste it from here into your IDE, and you would have a working program. Now, let’s take the same code and add comments so you can see what is going on:

 

For more detail: Arduino Lab 2 – Morse Code Generator

Quick Solutions to Questions related to Morse Code Generator:

  • How is the S.O.S. signal represented in Morse Code?
    The letters S.O.S. are transmitted as three dots, followed by a pause, then three dashes, another pause, and finally three dots.
  • What are the three programming versions provided for this lab?
    The code is presented in Bare-Bones, With Comments, and Subroutine versions to illustrate different programming possibilities.
  • Which Arduino pin is used for the wiring diagram?
    Pin 13 is used because it is hard-wired to the on-board LED marked L near that pin.
  • Can Morse Code be transmitted using light?
    Yes, Morse Code can be transmitted using light, often seen between ships at sea.
  • What is the standard international distress signal?
    The standard international distress signal is dot-dot-dot dash-dash-dash dot-dot-dot, known as SOS.
  • Does the subroutine version perform differently than the others?
    No, all three programs including the subroutine version perform exactly the same function.
  • Why is a resistor required in this project?
    A resistor with a value of 220 to 270 Ohms is required to complete the circuit safely.
  • What represents a dot in the text description of Morse Code?
    In the text description, dit represents dots or short transmissions.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top