Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Resistor 221 ohm
Breadboard (generic)
5 mm LED: Red
Project description
Code
For Loop Iteration
arduino
1/* 2 For Loop Iteration 3*/ 4 5int timer = 100; // The higher the number, the slower the timing. 6 7void setup() { 8 // use a for loop to initialize each pin as an output: 9 for (int thisPin = 2; thisPin < 8; thisPin++) { 10 pinMode(thisPin, OUTPUT); 11 } 12} 13 14void loop() { 15 // loop from the lowest pin to the highest: 16 for (int thisPin = 2; thisPin < 8; thisPin++) { 17 // turn the pin on: 18 digitalWrite(thisPin, HIGH); 19 delay(timer); 20 // turn the pin off: 21 digitalWrite(thisPin, LOW); 22 } 23 24 // loop from the highest pin to the lowest: 25 for (int thisPin = 7; thisPin >= 2; thisPin--) { 26 // turn the pin on: 27 digitalWrite(thisPin, HIGH); 28 delay(timer); 29 // turn the pin off: 30 digitalWrite(thisPin, LOW); 31 } 32} 33
Downloadable files
Breadboard Diagram
Breadboard Diagram

Schematic Diagram
Schematic Diagram

Comments
Only logged in users can leave comments