Decoding Morse Code (Using Arduino and Simple Tools)
by FredericWu in Circuits > Arduino
447 Views, 1 Favorites, 0 Comments
Decoding Morse Code (Using Arduino and Simple Tools)
Introduction to Morse code:
Morse code, one of the earliest forms of telecommunication codes. This code form is named after its inventor, Samuel Morse. After the creation of the telephone, this invention followed. In this kind of code, it uses dots and dashes, through different combinations, it indicates different English letters or Arabic numerals.
Briefly analyze the entire creation and how it works:
First, users will be able to enter the string they want in the serial monitor. After receiving the input string, Arduino will process it. The LCD screen displays the words or sentences entered by the user letter by letter. The red LED represents the point, and the other green LED represents the line (the color of the LED used in this article, everyone can change the color at will!). At the same time, the buzzer will “beep” for different durations accordingly.
This is a work derived from other people's creations:
https://www.instructables.com/Morse-code-with-ardu...
The extra features I added:
- LCD display screen: I added this function for the convenience of the user. The user can watch the LED blinking without looking at the computer.
- The LCD screen will display a complete word string at the end: This allows further usage and convenience for the user.
- String display time: In the original program, the string will be displayed after the LED light is turned on. This will make people who don’t understand Morse code feel clueless and don’t know what letter or number the LED is trying to represent
- Sound: I added a buzzer that originally didn't have. The Morse code was originally transmitted by sound and radio waves. The sound effect will definitely make the whole system better
- Another LED: I added a new one on top of the existing LED. The original long and short lights are all displayed by one LED, so it is difficult to distinguish between different signals. Adding an LED allows users to It is more convenient to use, and the difference between long and short signals becomes more obvious.
I added the functions stated above, I hope you will like this work and Morse code!
Preparing the Materials
The materials used in this project are very simple and easy to get
- Two LEDs
- A buzzer
- An LCD display screen
- Arduino
- breadboard
- A decorative box
- Computer used to process the program
Connect the Circuits
This step is very simple, just follow the circuit wiring above!
- LED;s long leg to D-pin short leg to gnd
- Buzzer's red wire connected to D-pin black wire connected to gnd
- LCD:
- Connect VCC to 5V
- gnd connect to gnd (ground)
- SDA and SCA are respectively connected to the corresponding pins on Arduino
Decoration!
Here I use a carton for packaging, which is not really beautiful. You can choose or use any decorations to decorate your device.
My Code
#include <Wire.h> // 改 #include <LiquidCrystal_I2C.h> //改 LiquidCrystal_I2C lcd_I2C_27(0x27,16,2); //改 int led =13;//the led pin int led2 = 12;// 改 int buzzer = 11;//改 int a = 0; //改 char input;// to save the input void setup () { pinMode (led,OUTPUT);//tell that the 13 pin is an output pinMode (led2,OUTPUT);//改 pinMode(buzzer, OUTPUT);//改 lcd_I2C_27.init (); // 改 lcd_I2C_27.backlight(); //改 Serial.begin(9600);//for the connect with the boared lcd_I2C_27.clear(); // 改 } void loop () { if (Serial.available()) { input = Serial.read();//read the input lcd_I2C_27.setCursor(a , 0) ; // 改 a += 1; //改 lcd_I2C_27.print(input); // 改 if (input == 'a' || input == 'A') {lA();}//if the input is a or A go to function lA if (input == 'b' || input == 'B') {lB();}//same but with b letter if (input == 'c' || input == 'C') {lC();} if (input == 'd' || input == 'D') {lD();} if (input == 'e' || input == 'E') {lE();} if (input == 'f' || input == 'F') {lF();} if (input == 'g' || input == 'G') {lG();} if (input == 'h' || input == 'H') {lH();} if (input == 'i' || input == 'I') {lI();} if (input == 'j' || input == 'J') {lJ();} if (input == 'k' || input == 'K') {lK();} if (input == 'l' || input == 'L') {lL();} if (input == 'm' || input == 'M') {lM();} if (input == 'n' || input == 'N') {lN();} if (input == 'o' || input == 'O') {lO();} if (input == 'p' || input == 'P') {lP();} if (input == 'q' || input == 'Q') {lQ();} if (input == 'r' || input == 'R') {lR();} if (input == 's' || input == 'S') {lS();} if (input == 't' || input == 'T') {lT();} if (input == 'u' || input == 'U') {lU();} if (input == 'v' || input == 'V') {lV();} if (input == 'w' || input == 'W') {lW();} if (input == 'x' || input == 'X') {lX();} if (input == 'y' || input == 'Y') {lY();} if (input == 'z' || input == 'Z') {lZ();} if (input == '1') {n1();}// the numbers if (input == '2') {n2();} if (input == '3') {n3();} if (input == '4') {n4();} if (input == '5') {n5();} if (input == '6') {n6();} if (input == '7') {n7();} if (input == '8') {n8();} if (input == '9') {n9();} if (input == '0') {n0();} if (input == ' ') {space();}//the space Serial.println (input);//print the latter saved in the input var } } //fonctions for the letters and the numbers void lA () {dot();dash();shortspace();}//letter A in morse code! void lB () {dash();dot();dot();dot();shortspace();}//same for B void lC () {dash();dot();dash();dot();shortspace();} void lD () {dash();dot();dot();shortspace();} void lE () {dot();shortspace();} void lF () {dot();dot();dash();dot();shortspace();} void lG () {dash();dash();dot();shortspace();} void lH () {dot();dot();dot();dot();shortspace();} void lI () {dot();dot();shortspace();} void lJ () {dot();dash();dash();dash();shortspace();} void lK () {dash();dot();dash();shortspace();} void lL () {dot();dash();dot();dot();shortspace();} void lM () {dash();dash();shortspace();} void lN () {dash();dot();shortspace();} void lO () {dash();dash();dash();shortspace();} void lP () {dot();dash();dash();dot();shortspace();} void lQ () {dash();dash();dot();dash();shortspace();} void lR () {dot();dash();dot();shortspace();} void lS () {dot();dot();dot();shortspace();} void lT () {dash();shortspace();} void lU () {dot();dot();dash();shortspace();} void lV () {dot();dot();dot();dash();shortspace();} void lW () {dot();dash();dash();shortspace();} void lX () {dash();dot();dot();dash();shortspace();} void lY () {dash();dot();dash();dash();shortspace();} void lZ () {dash();dash();dot();dot();shortspace();} void n1 () {dot();dash();dash();dash();dash();shortspace();}//number 1 in morse code void n2 () {dot();dot();dash();dash();dash();shortspace();} void n3 () {dot();dot();dot();dash();dash();shortspace();} void n4 () {dot();dot();dot();dot();dash();shortspace();} void n5 () {dot();dot();dot();dot();dot();shortspace();} void n6 () {dash();dot();dot();dot();dot();shortspace();} void n7 () {dash();dash();dot();dot();dot();shortspace();} void n8 () {dash();dash();dash();dot();dot();shortspace();} void n9 () {dash();dash();dash();dash();dot();shortspace();} void n0 () {dash();dash();dash();dash();dash();shortspace();} void space () {delay (1200);}//space between words void dot () {digitalWrite(led,HIGH); tone(buzzer, 500); delay (100); digitalWrite(led,LOW); noTone(buzzer); delay (200);}//改 void dash () {digitalWrite(led2,HIGH); tone(buzzer, 500); delay (300); digitalWrite(led2,LOW); noTone(buzzer); delay (200);}//改 void shortspace () {delay(600);}//改
FInal Product
After the copying the code, you can start the program and enter the any word or sentence into serial monitor. Hope you guys love it!