String morseDict[26]{".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..",};
char letterDict[26]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
String a;
void setup() {
// put your setup code here, to run once:
pinMode(5, OUTPUT);
Serial.begin(9600);
Serial.println("Hello!");
}
String blinkLED(String input){
Serial.println(input);
char output;
for (int b = 0; b < input.length(); b++){
output = input[b];
Serial.println(output);
if (output == '.'){
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
}
if (output == '-'){
digitalWrite(5,HIGH);
delay(3000);
digitalWrite(5,LOW);
}
if (output == ' '){
delay(1000);
}
delay(300);
}
}
String convertToMorse(String sentence){
char CurrentChar;
int CurrentOutput;
sentence.toUpperCase();
for(int i = 0; i < sentence.length(); i++){
CurrentChar = sentence[i];
CurrentOutput = CurrentChar-65;
blinkLED(morseDict[CurrentOutput]);
}
}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available()){
a = Serial.readString();
Serial.println(convertToMorse(a));
}
}