For Loop

For Loop

See Also:

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the digitalWrite() and delay() functions .

to:

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the digitalWrite() and delay() functions .

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the digitalWrite() and delay() functions .

to:

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the digitalWrite() and delay() functions .

In the main loop of the code, two for() loops are used to loop incrementally, turning on the LEDs, one by one, connected to lowest pin to the highest.

to:

In the main loop of the code, two for() loops are used to loop incrementally, stepping through the LEDs, one by one, from pin 2 to pin seven. Once pin 7 is lit, the process reverses, stepping back down through each LED.

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the [Reference/digitalWrite | digitalWrite()]] and delay() functions .

to:

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the digitalWrite() and delay() functions .

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs, one by one, attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7.

to:

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7. The LEDS are turned on and off, in sequence, by using both the [Reference/digitalWrite | digitalWrite()]] and delay() functions .

Deleted lines 9-10:

This example makes use of 6 LEDs connected to the pins 2 - 7 on the board using 220 Ohm resistors. The sketch makes the LEDs blink in a sequence, one by one using only digitalWrite() and delay() .

This example makes use of 6 LEDs connected to the pins 2 - 7 on the board using 220 Ohm resistors. The sketch makes the LEDs blink in a sequence, one by one using only digitalWrite(pinNumber,HIGH/LOW) and delay(time).

to:

This example makes use of 6 LEDs connected to the pins 2 - 7 on the board using 220 Ohm resistors. The sketch makes the LEDs blink in a sequence, one by one using only * digitalWrite() and * delay() .

Often you want to iterate over a series of pins and do something to each one. For instance, this example lights 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7.

to:

Often you want to iterate over a series of pins and do something to each one. For instance, this example blinks 6 LEDs, one by one, attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7.

Often you want to iterate over a series of pins and do something to each one. For example, this example lights up a series of LEDs attached to pins 2 through 7 of the Arduino.

to:

Often you want to iterate over a series of pins and do something to each one. For instance, this example lights 6 LEDs attached the Arduino by using a for() loop to cycle back and forth through digital pins 2-7.

Whileloop? - Use a While Loop to calibrate a sensor while a button is being pressed.

Switchcase? - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.

WhileLoop - Use a While Loop to calibrate a sensor while a button is being pressed.

SwitchCase - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.

While Loop? - Use a While Loop to calibrate a sensor while a button is being pressed.

Switch Case? - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.

Whileloop? - Use a While Loop to calibrate a sensor while a button is being pressed.

Switchcase? - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.

While Loop? - Use a While Loop to calibrate a sensor while a button is being pressed.

Switch Case? - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.

Array: a variation on the For Loop example that demonstrates how to use an array.

/* For Loop Iteration Demonstrates the use of a for() loop. Lights multiple LEDs in sequence, then in reverse. The circuit: * LEDs from pins 2 through 7 to ground created 2006 by David A. Mellis modified 5 Jul 2009 by Tom Igoe http://www.arduino.cc/en/Tutorial/ForLoop */