Right now, I have the following switch-case, built using an enum representing some text.
String inputMessage = Serial.readString(); //Input is either TEXT_1 or TEXT_2.
enum Messages {
TEXT_1, TEXT_2
};
enum Messages currentMessage = TEXT_2;
switch (currentMessage) {
case TEXT_1:
Serial.println("RESPONSE_1");
break;
case TEXT_2:
Serial.println("RESPONSE_2");
break;
default:
break;
I am trying to get to a point where the contents of a String (this is Arduino C code), inputMessage, which will be TEXT_1 or TEXT_2, to control currentMessage, which will control the switch-case. I would like to avoid an if-else stack if possible (thus, the switch-case attempt) since I do intend to scale up the number of TEXT to a much higher number in the future.
Please let me know if more information is required.