Go Down

Topic: "switch quantity not an integer"? (Read 3211 times) previous topic - next topic

flickerfly

In comparing the documentation at http://arduino.cc/en/Reference/SwitchCase, it doesn't say anything about the case statement requiring an integer. I tried using a float and it complained that it wasn't an integer. Can I not use a float? (If so, could a mention be made on the reference page for others to clarify that. :-)

Also, can an operator be used in a case? For example

switch (time) {
 case >300:
   do something;
 case >200:
   do something else;
 default:
}

kg4wsv

you can't use a float or an expression in a switch statement.

I'd recommend a set of if/else blocks.

-j


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy