/* * Morse Code Communication * Receiver Section * by * Pranav Arora * ECE, SRM University */ int sensorPin = 0; // select the input pin for ldr int sensorValue = 0; // variable to store the value coming from the sensor int a, f; // flags void setup() { Serial.begin(9600); //sets serial port for communication } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor //Serial.println(sensorValue); if(sensorValue>1000)// calculating the number of dots and dashes { for(int i=0;i<=13;i++) { sensorValue=analogRead(sensorPin); if(sensorValue>1000) { a++; //calculating the number of dots and dashes in the character delay(200); } else { f++; // calculating the number of spaces in dots and dashes delay(200); } } } //Serial.print("a= "+a); //Serial.println("f= "+f); //Serial.println(); /* * Checking the set of dots, dashes and spaces */ if(a==4 && f==10) { Serial.print("a"); } if(a==6 && f==8) { Serial.print("b"); } if(a==8 && f==6) { Serial.print("c"); } if(a==1 && f==13) { Serial.print("e"); } if(a==2 && f==12) { Serial.print("i"); } if(a==10 && f==4) { Serial.print("j"); } if(a==7 && f==7) { Serial.print("g"); } if(a==9 && f==5) { Serial.print("o"); } if(a==3 && f==11) { Serial.print("s"); } f=a=0; delay(200); }