Project showcase

Morse Code Receiver © MIT

It's a Morse code receiver base on processing the light signals.

  • 2,988 views
  • 5 comments
  • 22 respects

Components and supplies

Apps and online services

About this project

This project is about a Morse code receiver. You will need Arduino board:

Oled Display on anything you want to use:

Connecting the OLED to Arduino:

According to C++ CODE:

#define OLED_MOSI  11   //D1
#define OLED_CLK   12   //D0
#define OLED_DC    9
#define OLED_CS    8
#define OLED_RESET 10 

Then connect the potentiometer and photoresistor. Download the Morse code app from GooglePlay:

Code

CodeC/C++
morse tree adapted from code written by Achindra Bhatnagar
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// If using software SPI (the default case):
#define OLED_MOSI  11   //D1
#define OLED_CLK   12   //D0
#define OLED_DC    9
#define OLED_CS    8
#define OLED_RESET 10


Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


const char MorseTree[] = {'\0','E', 'T', 'I', 'A', 'N', 'M', 'S',
                          'U', 'R', 'W', 'D', 'K', 'G', 'O', 'H',
                          'V', 'F', 'U', 'L', 'A', 'P', 'J', 'B',
                          'X', 'C', 'Y', 'Z', 'Q', '\0','\0','5',
                          '4', '\0','3', '\0','\0','\0','2', '\0',
                          '\0','+', '\0','\0','\0','\0','1', '6',
                          '=', '/', '\0','\0','\0','(', '\0','7',
                          '\0','\0','\0','8', '\0','9', '0', '\0',
                          '\0','\0','\0','\0','\0','\0','\0','\0',
                          '\0','\0','\0','?', '_', '\0','\0','\0',
                          '\0','"', '\0','\0','.', '\0','\0','\0',
                          '\0','@', '\0','\0','\0','\0','\0','\0',
                          '-', '\0','\0','\0','\0','\0','\0','\0',
                          '\0',';', '!', '\0',')', '\0','\0','\0',
                          '\0','\0',',', '\0','\0','\0','\0',':',
                          '\0','\0','\0','\0','\0','\0','\0'
                         };


int val = 0; // A Variable to Store the Light Value from the LDR
int ctrHigh = 0;
int ctrLow = 0;
int codePtr = 0;
int dotLen;
bool Bflag;
int wpm;
 static unsigned long thisMicros = 0;
  static unsigned long lastMicros = 0;

void setup()
{
  
 display.begin(SSD1306_SWITCHCAPVCC);
  display.display();
  delay(1000);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);

  Serial.begin(9600);// Start a Serial Connection
  Serial.print(codePtr);
}

void loop()
{
 
  getMorse();


  
}











void dis(){
  display.display();
 lastMicros = thisMicros;
 thisMicros = micros();
}












void getMorse(){
    wpm = (analogRead(2)*10)/1023 ;
    val = analogRead(1);
    ///////////////////
    if (wpm == 1){
      dotLen = 63;
    }
    if (wpm == 2){
      dotLen = 125;
    }
    if (wpm == 3){
      dotLen = 187;
    }
    if (wpm == 4){
      dotLen = 250;
    }
    if (wpm == 5){
      dotLen = 312;
    }
   if (wpm == 6){
      dotLen = 375;
    }
    if (wpm == 7){
      dotLen = 737;
    }

        if (wpm == 8){
      dotLen = 500;
    }
        if (wpm == 9){
      dotLen = 562;
    }
        if (wpm == 10){
      dotLen = 625;
    }
    ////////////////////
    
//  Serial.println(wpm);
  if (val >= 300)
  {
    ctrHigh++;
    ctrLow = 0;
//    digitalWrite(13, HIGH);
 //   tone(9, 1000);
  } else {
    ctrLow++;
    if ((ctrHigh >= dotLen) && (ctrHigh < dotLen*2)) {
    //  Serial.print(".");
    Bflag =true;
      codePtr = (2*codePtr) + 1;
    } else if (ctrHigh >= dotLen * 2) {
      Bflag =true;
    //  Serial.print("-");
      codePtr = (2*codePtr) + 2;
    } else {
      if(ctrLow >= dotLen*6 && Bflag == true){
         Serial.print(" ");
          display.print(" ");
          Bflag = false;
      }
       if(ctrLow >= dotLen*14){
           display.clearDisplay();
            display.setCursor(0,0);
      }
      if(ctrLow == dotLen*2){
        
        Serial.print(MorseTree[codePtr]);
    display.print(MorseTree[codePtr]);
    dis();
        codePtr = 0;
      }
    }

    ctrHigh = 0;
//    digitalWrite(13, LOW);
//    noTone(9);
  }
}

Comments

Similar projects you might like

Morse Code Transmitter - Light Signal

Project showcase by Alireza Karkon

  • 975 views
  • 1 comment
  • 6 respects

Morse Code Communication Using Arduino

Project tutorial by Jalal_Mansoori

  • 470 views
  • 0 comments
  • 5 respects

Morse Code Translator

Project showcase by Team ONYX

  • 8,336 views
  • 2 comments
  • 13 respects

Morse Code S.O.S. Flasher

Project showcase by Team ONYX

  • 7,596 views
  • 0 comments
  • 9 respects

Morse Code Communication Using Laser Module (Both)

Project tutorial by SURYATEJA

  • 604 views
  • 0 comments
  • 6 respects

Morse Code Transceiver

Project tutorial by Achindra Bhatnagar

  • 14,184 views
  • 12 comments
  • 83 respects
Add projectSign up / Login