Now I will tell you how to use "Switch and Case" in Arduino. You can use it instead of "if". 
Here you can see a code:
int i = Random(5); //generate Random number from 0 to 4
switch(i)
{
  case 0:
    //Action if value is 0
    break;
  case 1:
    //Action if value is 1
    break;
  case 2:
    //Action if value is 2
    break;
  case 3:
    //Action if value is 3
    break;
  case 4:
    //Action if value is 4
    break;
}
 
No comments:
Post a Comment