My Morse Code

tags: Morse DSNA 22 Button LED

Lets Send som Morse code and light related LEDS

:memo: How it Works ?

Step 1: Connect it well

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

:rocket:

Step 2: Easy code

// Summary: This program is simulation to Morse code we send dots and dashes

// we ganna use 3 functions : 
// 1) dot()  : that that buzz and light the related led
//     
// 2) dash() : that buzz longer and light another led
// 3) Which_Button : that return which Button we presed ( BLue button for //Dot , Red for     dash)
// the Leds : Green when send a dot , Red when send a dash.
//           
// The sound : 2 diferent Melodies for dot and for dash.
//
// Version: 1.0
// Owner: Ammar alnahhas 
// ---------------------------------------------------------------
// Log: 2020-11-16  Created the file. 
//     2020-11-16  Tested all values and Nich values also!
//

#define NOTE_Dot 523
#define NOTE_Dash 587

// input Buttoms Pin
const byte myPin2 =2;
const byte myPin3 =3;

// output Leds pin
const byte myPin10=10;
const byte myPin11=11;

// Buzzer
const byte myBuzzer =8;

// Parameter
int chosed = 0;
void setup() {
  // input Pin
  pinMode(myPin2,INPUT);
  pinMode(myPin3,INPUT);
 
  // output pin
  pinMode(myPin10,OUTPUT);
  pinMode(myPin11,OUTPUT);
 
  pinMode(myBuzzer,OUTPUT);

// Computer output 
   Serial.begin(9600);
  
  // Welcoming screen on Serial 
  Serial.println("Welcome to Morse Sender");
  Serial.println(" ======================");




}

void loop() {
  chosed = Which_Button();

  switch (chosed)
  {
    case 0: //DOT
    dot();
    break;
    
    case 1: // Dash
    dash();
    break;
  }
  

}



void dot()
{
  tone(myBuzzer, NOTE_Dot);
  delay(100);
  noTone(myBuzzer);
  digitalWrite(myPin10, HIGH);
  delay(250);
  digitalWrite(myPin10, LOW);
  delay(250);
}

void dash()
{
  tone(myBuzzer, NOTE_Dash);
  delay(200);
  noTone(myBuzzer);
  digitalWrite(myPin11, HIGH);
  delay(250);
  digitalWrite(myPin11, LOW);
  delay(250);
}


int Which_Button(void)
{
  int buttonState_Dot = 0;
  int buttonState_Dash = 0;
   Serial.println( "Dot or Dash ");
   delay(200);
 while (1){
 buttonState_Dot = digitalRead(myPin2);
 buttonState_Dash = digitalRead(myPin3);
  
 if ( buttonState_Dot == HIGH)
 {Serial.println("DOT") ;
  return 0;}
 else if (buttonState_Dash ==HIGH)
 {Serial.println("DASH") ; 
  return 1;}
 
}
}

BONUS: A Vedio Till:

  • YouTube Video :

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

DSNA22 OTHER Projects :

Last but not least Thanks :

Thanks for Thomas Berggren for all knowledge and experience that looks clearly in backscenes of this project!