Arduino Morse code, with LDRs and button

Hi Guys,
I'm trying to create a code that makes this morse code project possible. My idea is to use two LDRs as buttons. One for the dot and one for the dash. And one button to start and stop the chain of LDRs responding. And i'm using a buzzer to make the appropriate sound based on which LDR picks up the touch.

The thing i am wanting some advice with is how to add in an array to the code, to be able to remember what order i pressed the LDRs in and then present what letter I made when i lift my finger off the button.

Thank you in Advance.

Here is my code so far:

int Dot=0;
int Dash=0;
int buzzerPin = 3;
void setup() {
Serial.begin(9600);
pinMode(6,OUTPUT);
pinMode(buzzerPin,OUTPUT);
}

void loop() {
Serial.println(analogRead(A0));
while(digitalRead(6)==0){
}
if(analogRead(A0)<60) {
Dot=Dot+1;
Serial.println(Dot);
tone(3, 200, 500); // pin frequency duration
delay(750);
}
Serial.println(analogRead(A1));
if(analogRead(A1)<=60) {
Dash=Dash+1;
Serial.println(Dash);
tone(3, 200, 1000); // pin frequency duration
delay(750);
}
Serial.println(analogRead(A0 && A1));
if(Dash==1 && Dot==1) {
Serial.println("A");
}
}

Hello
take a search engine an ask the WWW for morse tree.
You need to implement this tree however you want in your sketch.
gd dx

1 Like

Thank you, Sorry to be a pain. But how would i do that?

Hello
at least you need three timer:

  • dot-timer
  • dash-timer
  • dash timeout
    when you cover the related LDR a dash or dot sign will be generated.
    When the dash-timer timed out you have generate a character.

Well, or take a view here:
https://create.arduino.cc/projecthub/projects/tags/morse+code

1 Like