I trigger an "if" with a Telegram message, which makes a motor go at a certain speed.
While the first "if" plays only once and then jumps to the "else" (which I'm also not sure if I understand it correctly), the other "if" just never stops.
But briefly, an if statement will keep executing as long as the condition remains true.
So, if you don't want an if to execute, you need to clear the condition somewhere.
I'm not sure what you are asking, however sometimes it is helpful to just consider the conditions without what is actually done. Like this...
if (text == "Action One") {
// Action one stuff
}
if (text == "Action Two") {
// Action two stuff
}
else {
// else stuff
}
With this logic if text contains the string "Action One" then obviously the first if code block will execute. The second if code block will not execute because text does not contain the string "Action Two" and therefore will execute the else code block. If you only want the else block to execute if text does not contain "Action One" or "Action Two" then you need to use an else if. Like this:
if (text == "Action One") {
// Action one stuff
}
else if (text == "Action Two") {
// Action two stuff
}
else {
// else stuff
}