# Multiple layers using if-else

**URL:** <https://forum.arduino.cc/t/multiple-layers-using-if-else/265432>\
**Category:** Syntax & Programs\
**Created:** [October 25, 2014, 4:45pm UTC](https://forum.arduino.cc/t/multiple-layers-using-if-else/265432 "2014-10-25T16:45:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goldenshuttle](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/goldenshuttle/32/217448_2.png) [@Goldenshuttle](https://forum.arduino.cc/u/Goldenshuttle)\
**Post date:** [October 25, 2014, 4:45pm UTC](https://forum.arduino.cc/t/multiple-layers-using-if-else/265432/1 "2014-10-25T16:45:47Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 8:13pm UTC](https://forum.arduino.cc/t/multiple-layers-using-if-else/265432/2 "2021-05-06T20:13:15Z")

</div>


