Project showcase
Morse Code Translator

Morse Code Translator © GPL3+

In this project, we will print out Morse Code of a sentence typed in Serial Monitor by flashing LED for each word and space between them.

  • 18,486 views
  • 9 comments
  • 23 respects

Components and supplies

Apps and online services

About this project

This project is used to read morse code with help of Flashing LED:

Code

Morse Code TranslatorArduino
int ledPin = 8;

//For letters
char* letters[] = {
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", // A-I
".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", // J-R 
"...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.." // S-Z
};

//For Numbers
char* numbers[] = {
  "-----", ".----", "..---", "...--", "....-", ".....",
"-....", "--...", "---..", "----."
};
int dotDelay = 200;

void setup() {
  // put your setup code here, to run once:

  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  char ch;
if (Serial.available())
{
ch = Serial.read(); // read a single letter if (ch >= 'a' && ch <= 'z')
if (ch >= 'a' && ch <= 'z')
{
flashSequence(letters[ch - 'a']);
}
else if (ch >= 'A' && ch <= 'Z') {
flashSequence(letters[ch - 'A']); }
else if (ch >= '0' && ch <= '9') {
flashSequence(numbers[ch - '0']); }
else if (ch == ' ') {
delay(dotDelay * 4);
}
}

}

void flashSequence(char* sequence) {
int i = 0;
while (sequence[i] != NULL) {
        flashDotOrDash(sequence[i]);
i++; }
delay(dotDelay * 3);
}


void flashDotOrDash(char dotOrDash) {
digitalWrite(ledPin, HIGH); if (dotOrDash == '.')
{
    delay(dotDelay);
  }
else // must be a - 
{
delay(dotDelay * 3); }
digitalWrite(ledPin, LOW); delay(dotDelay);
}

Schematics

Final Result in Serial Monitor
Hit enter after typing word or sentence to see your LED flash in morse Code
Screen%20shot%202016 06 26%20at%204.34.17%20pm
Schematic
Finalmorse

Comments

Similar projects you might like

Morse Code Transmitter - Light Signal

Project showcase by Alireza Karkon

  • 2,990 views
  • 1 comment
  • 7 respects

Morse Code Communication Using Arduino

Project tutorial by Jalal_Mansoori

  • 9,743 views
  • 17 comments
  • 30 respects

Morse Code Receiver

Project showcase by Alireza Karkon

  • 5,176 views
  • 5 comments
  • 25 respects

Arduino Morse Code Machine

Project showcase by Vlada Krsmanovic

  • 13,572 views
  • 2 comments
  • 36 respects

Morse Code Communication Using Laser Module (Both)

Project tutorial by SURYATEJA

  • 2,201 views
  • 1 comment
  • 12 respects

Morse Code Machine

Project showcase by brzi

  • 3,829 views
  • 1 comment
  • 7 respects
Add projectSign up / Login