I'm using a teensy 2.0 with SD adapter and I'm not a programmer but I made a joke keyboard that switches out certain typed words. For example if they type "monkey" it replaces it with "andrew". Right now I am using a string to capture the last 20 characters typed, then I have a big else if to check for certain keywords using endsWith("keyword"). This approach works great for upto 40 keywords then it stops working, I assume its the memory getting filled from the giant else if (using 85% of storage). I read switches are more efficient but it only uses single chars/integers. Is there a way to switch on a string or have another idea to solve this? Thanks.
Here is small part of the else if so you get the idea, I call files so I can change the words without messing with uploading another sketch, I can just pop out the SD card and change the words, but the keywords stay the same.
//monkey
if (lasttwenletters.endsWith("monkey")) {
TypeOutFile("MONKEY.TXT"); //types out the file to keyboard
lasttenletters[19]='*'; //change character
}
//there
else if (lasttwenletters.endsWith("there")) {
TypeOutFile("THERE.TXT");
lasttenletters[19]='*'; //change character
}
//ask
else if (lasttwenletters.endsWith("ask")) {
TypeOutFile("ASK.TXT");
lasttenletters[19]='*'; //change character
}