Arduino: for loop simply explained
The for loop is very practical on the Arduino. You can find out how it works in this practical tip.
for loop on the Arduino: All information
The syntax of the for loop for the Arduino is "for (initialization; condition; increment / decrement) {".
- Instead of "initialization;" for example, you can use "int x = 1;" Instead of "condition", write a condition such as »x <= 5;«. Finally, instead of "increment / decrement" you can write a command like »x ++«.
- The loop in our example would now count from 1 to 5.
- However, instead of "x ++" you can also use other commands such as "x = x + 5".
- Tip: In addition to the "break;" command, which causes the loop to be terminated, there is also the "continue;" command, which causes the loop to skip one step (or the remaining commands).
In the next practical tip you will learn how classes work in Java.