Is there a possibility to add an else after a while-Loop in Arduino, like there is in Java or C#? Something like this:
while(condition){
doThingA;
} else{
doThingB;
}
C# does not have while...else and I don't think Java has this construct either. Python has it and because the instructions in the else block are not executed only when you break from the loop you can emulate it as follows:
bool flag = TRUE;
while (condition)
{
if (anothercondition)
{
flag = FALSE;
break;
}
}
if (flag)
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With