I'm trying to do Morse Code Decoder on Processing 3. I have codes for Morse Code Encoder. But I'm struggling about convert encoder to decoder.
Also I want to enter Morse Code with clicking, but it's going to be next step after the conversion.
I tried to change inputs and outputs and alphabets to the morse, but in the last section of the code, i stucked.
Here is the original encoder : https://www.openprocessing.org/sketch/134812/
Here is my modified decoder code:
String textInput;
String textOutput;
void setup() {
textInput = decodeMorseCode(textInput);
textOutput = "";
println("Morse code: " + textInput);
println("Text output: " + textOutput);
}
void draw() {
}
String decodeMorseCode(String in_string) {
String MorseCodeInput = in_string.toLowerCase();
String TextOutput = new String();
String[] MorseCodeArray = {
"._", "_...", "_._.", "_..", ".", ".._.", "__.", "....", "..", ".___", "_._", "._..", "__",
"_.", "___", ".__.", "__._", "._.", "...", "_", ".._", "..._", ".__", "_.._", "_.__", "__.."
};
String[] AlphabetArray = {
"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"
};
for (int i=0; i<TextInput.length(); i++) {
for (int j=0; j<AlphabetArray.length; j++) {
if (String.valueOf(TextInput.charAt(i)).equals(AlphabetArray[j])) {
MorseCode += MorseCodeArray[j] + " " ;
}
}
}
return MorseCode;
}
I'm getting an error on the line "for (int i=0; i
If it's going to be work properly it should decode morse to text.