Hi,
I am new and learning programming Arduino.
This Moment I have a Problem with Switch - Case Function
Is it possible to use this:
Switch (GPSSpeed); // Integer
case >=100:
case >=50 <100:
case >=10 <50:
case <10:
Thank's for help !!!
Hi,
I am new and learning programming Arduino.
This Moment I have a Problem with Switch - Case Function
Is it possible to use this:
Switch (GPSSpeed); // Integer
case >=100:
case >=50 <100:
case >=10 <50:
case <10:
Thank's for help !!!
No.
Single compile time constants, or contiguous ranges (with ellipses)
If you google “ Arduino case” you will find the syntax for this instruction.
You can’t do what you propose, you can only work with single values for each case
if (x >= 100)
{
}
else if (x >= 50)
{
}
else if (x >= 10)
{
}
else // x < 10
{
}
Try writing your case statements in reverse order and use only the < test to keep it easy. Logically the first step processes everything less then 10. The second process everything less then 50, be sure to use the break; statement that way once a case is executed the process exits.
Good Luck & Have Fun!
Gil