Alireza Karkon
Published © CC BY

Morse Code Transmitter - Light Signal

In this project I made a Morse code transmitter using Arduino and Winform application.

IntermediateShowcase (no instructions)3 hours7,011

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE
Visual Studio 2015
Microsoft Visual Studio 2015

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

WINDOWSFORM APPLICATION

MORSE.EXE

Schematics

Circuit

Code

Arduino Code

C/C++
int mrs = 7; 
int slsh = 4; 
int spc = 10; 
int ddot=100;
int ddash=500;
void setup() { 
  Serial.begin(9600);
pinMode(mrs, OUTPUT); 
pinMode(slsh, OUTPUT); 
pinMode(spc, OUTPUT); 
}

void loop() { 

}
//////////////////
String Splitter(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;
    

    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}
///////////////////////////
void serialEvent (){
  String serialResponse = Serial.readString();
  int _length = serialResponse.length();
  String morse[_length];
  for(int i = 0 ; i <= _length ; i++)
  {
     morse[i] = Splitter(serialResponse, '`', i);
  }
  for (int j = 0 ; j <=_length ; j++)
  {
    if(morse[j]==".")dot();
    else if(morse[j]=="-")dash();
    else if(morse[j]=="/")slash();
    else if(morse[j]=="s")space();
  }Serial.println("End");
  
}
void space ()
{
 // Serial.println("space ");
  digitalWrite(spc, HIGH); 
delay(500); 
digitalWrite(spc, LOW); delay(400);
}
void slash ()
{
//  Serial.println("slash ");
  digitalWrite(slsh, HIGH); 
delay(1600); 
digitalWrite(slsh, LOW); delay(400);
}
void dot ()
{
//  Serial.println("dot ");
  digitalWrite(mrs, HIGH); 
delay(ddot); 
digitalWrite(mrs, LOW); delay(400);
}
void dash ()
{
//  Serial.println("dash ");
  digitalWrite(mrs, HIGH); 
delay(ddash); 
digitalWrite(mrs, LOW); delay(400);
}

Credits

Alireza Karkon

Alireza Karkon

10 projects • 67 followers
Hey guys! I'm Alireza. I'm a student (Bachelor of Technology)-Computer EngrgTech. I'm C# / C++ / Unity programmer and familiar to Front-End.

Comments