-
Book Overview & Buying
-
Table Of Contents
C Programming for Arduino
By :
A loop is a series of events repeating themselves in time. Basically, computers have been designed, at first, to make a lot of calculations repeatedly to save human's time. Designing a loop to repeat tasks that have to be repeated seems a natural idea. C natively implements some ways to design loops. Arduino core naturally includes three loop structures:
for
while
do…while
The for loop statement is quite easy to use. It is based on, at least, one counter starting from a particular value you define, and increments or decrements it until another defined value. The syntax is:
for (declaration & definition ; condition ; increment) {
// statements
}The counter is also named index. I'm showing you a real example here:
for (int i = 0 ; i < 100 ; i++) {
println(i);
}This basic example defines a loop that prints all integers from 0 to 99. The declaration/definition of the integer type variable i is the first element of the for structure...
Change the font size
Change margin width
Change background colour