Programming 'While Loops'

Under the while loops, does it matter if I only use the ‘If’ statements instead of the ‘Else-If’ statements?


You can use them all you want.

you can use any loop within a while loop. you can only use an else-if loop after an if loop.

You can program any way you would like but it is worth knowing when to use what statements.

If else statements are great for when there is more than one variable that can affect the outcome.

Button 1 needs to raise the arm.
Button 2 needs to lower the arm.
Nothing pressed needs to stop the arm.

You have three possible inputs that control a single motor, this is when an If Else statement would come in handy.

Now, if you have just a single input and task an If statement should be all you need.

If Switch 1 is pressed stop all motors.

Hope this helps!