Go Down

Topic: Multiple layers using if-else  (Read 81 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