Go Down

Topic: Multiple layers using if-else  (Read 341 times) previous topic - next topic

Goldenshuttle

Say I have 4 switches controlling 2 servos,  can I use this block

if SW1==1 && SW2==0 && SW3=0 && SW4==0
{servo1.write(30);servo2.write(60);}
else if SW1==1 && SW2==1 && SW3=0 && SW4==0
{servo1.write(60);servo2.write(90);}
else if SW1==1 && SW2==1 && SW3=1 && SW4==0
{servo1.write(90);servo2.write(120);}
else if SW1==1 && SW2==1 && SW3=1 && SW4==1
{servo1.write(120);servo2.write(150);}


if the answer is yes, how many layers of  if-else one can use? is there a limit ?
One wishes 2 live 1000 yrs 2 read all the great books in ths world. But as the world is getting worse with time; never mind about the books.

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