Morse Code Decoder

  1. Introduction:-

In this project we will be constructing a Morse code decoder using an arduino UNO. The decoder will convert the text entered in Morse code into the English language.

  1. Components Required:-

(i) 330 ohm resistor x 5
(ii) 10 K ohm resistor x 5
(iii) Pushbutton x 5
(iv) LED x 5
(v) Arduino UNO R3
(vi) Breadboard
(vii) Connecting wires

  1. Explanataion:-

Connect the circuit as shown in the circuit diagram, each pushbutton when pressed prints a different character on the serial monitor and glows an LED of different colour.
One pushbutton prints dots(.), one pushbutton prints dashes(-), one pushbutton is used to give space( ) between two words, one pushbutton is used to store and scan the values of the input in an empty array and one pushbutton is used to translate the Morse code into the English language.

The pushbutton connected to digital pin 5 needs to be pressed after the input of every character(i.e. letter, number or space) to scan the value of the input and store it into an empty array.
Please note that the pushbutton connected to digital pin 5 needs to be pressed after input of every character in the English language not according to the Morse code, i.e
we do not need to scan after inputting every dot or dash but after inputting a recognized value or character of the English language. For example A in Morse code is .-
we need not press the button after . and then again after – instead we print .- in the serial monitor using the assigned pushbuttons and then scan it, similarly we need to scan after giving space as well.

  1. Code:-

int dot=2;
int dash=3;
int next=5;
int space=6;
int translate=7;
int red=8;
int yellow=9;
int green=11;
int blue=12;
int white=13;
String alphabet[]={“.-“, “-…”, “-.-.”, “-..”, “.”, “..-.”, “–.”, “….”, “..”, “.—“, “-.-“, “.-..”, “–“, “-.”, “—“, “.–.”, “–.-“, “.-.”, “…”, “-“,
“..-“, “…-“, “.–“, “-..-“, “-.–“, “–..”};
String number[10]={“—–“, “.—-“, “..—“, “…–“, “….-“, “…..”, “-….”, “–…”, “—..”, “—-.”};
String next_letter= “”;
String decoded= “”;
void setup(){
Serial.begin(9600);
Serial.println(“Enter your morse code”);
pinMode(dot,INPUT);
pinMode(dash,INPUT);
pinMode(next,INPUT);
pinMode(space,INPUT);
pinMode(translate,INPUT);
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(green,OUTPUT);
pinMode(blue,OUTPUT);
pinMode(white,OUTPUT);
}
void loop(){
if(digitalRead(2)==HIGH){
Serial.print(“.”);
digitalWrite(red,HIGH);
delay(200);
digitalWrite(red,LOW);
next_letter += “.”;
}
if(digitalRead(3)==HIGH){
Serial.print(“-“);
digitalWrite(yellow,HIGH);
delay(200);
digitalWrite(yellow,LOW);
next_letter= next_letter + “-“;
}
if(digitalRead(5)==HIGH){
Serial.print(“@”);
digitalWrite(green,HIGH);
delay(200);
digitalWrite(green,LOW);
for(int i=0; i<26; i++){
if(next_letter==alphabet[i]){
decoded+=(char)(65+i);
}
}
for(int j=0; j<=9; j++){
if(next_letter==number[j]){
decoded+=(char)(48+j);
}
}
next_letter=””;
}
if(digitalRead(6)==HIGH){
Serial.print(” “);
digitalWrite(blue,HIGH);
delay(200);
digitalWrite(blue,LOW);
decoded+=” “;
}
if(digitalRead(7)==HIGH){
digitalWrite(white,HIGH);
delay(200);
digitalWrite(white,LOW);
Serial.println(“Translation of morse code is:”);
Serial.println(decoded);
}
}

Connect the circuit according to the shown schematic.
Circuit diagram

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.