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");
}
}