If someone types "red", then input = "red". This part works. What I now want is for it to call red() without writing an if statement (since I have so many functions it would take a lot of ifs). All functions follow this format:
The simplest way to achieve it would be with a switch statement something like this
String input;
char commands[3][6]={"red","green","blue"};
int n;
while(!Serial.available()){
}
input = Serial.readString();
for (n=0;n<3;n++)
if(input==commands[n])
switch(n)
{
case 1:red();break;
case 2:green();break;
case 3:blue();break;
}
Although, personally, I'd rather go with a char array for my input, and then use strcmp (instead of the ==) but this would make your Serial.read slightly more complex.