Devices & Components
Arduino Uno Rev3
5 mm LED: Red
Solderless Breadboard Full Size
LilyPad LED White (5pcs)
Male/Male Jumper Wires
5 mm LED: Yellow
5 mm LED: Green
LilyPad LED Blue (5pcs)
Software & Tools
Arduino IDE
Project description
Code
Arduino code
arduino
1//www.youtube.com/Electronics is Fun// 2//www.facebook.com/Electronics is Fun// 3//Project by MOHD SOHAIL// 4 5 6int pinsCount=10; // declaring the integer variable pinsCount 7int pins[] = {2,3,4,5,6,7,8,9,10,11}; // declaring the array pins[] 8 9void setup() { 10 for (int i=0; i<pinsCount; i=i+1){ // counting the variable i from 0 to 9 11 pinMode(pins[i], OUTPUT); // initialising the pin at index i of the array of pins as OUTPUT 12 } 13} 14 15void loop() { 16 for (int i=0; i<pinsCount; i=i+1){ // chasing right 17 digitalWrite(pins[i], HIGH); // switching the LED at index i on 18 delay(100); // stopping the program for 100 milliseconds 19 digitalWrite(pins[i], LOW); // switching the LED at index i off 20 } 21 for (int i=pinsCount-1; i>0; i=i-1){ // chasing left (except the outer leds) 22 digitalWrite(pins[i], HIGH); // switching the LED at index i on 23 delay(100); // stopping the program for 100 milliseconds 24 digitalWrite(pins[i], LOW); // switching the LED at index i off 25 } 26}
Arduino code
arduino
1//www.youtube.com/Electronics is Fun// 2//www.facebook.com/Electronics is Fun// 3//Project by MOHD SOHAIL// 4 5 6int pinsCount=10; // declaring the integer variable pinsCount 7int pins[] = {2,3,4,5,6,7,8,9,10,11}; // declaring the array pins[] 8 9void setup() { 10 for (int i=0; i<pinsCount; i=i+1){ // counting the variable i from 0 to 9 11 pinMode(pins[i], OUTPUT); // initialising the pin at index i of the array of pins as OUTPUT 12 } 13} 14 15void loop() { 16 for (int i=0; i<pinsCount; i=i+1){ // chasing right 17 digitalWrite(pins[i], HIGH); // switching the LED at index i on 18 delay(100); // stopping the program for 100 milliseconds 19 digitalWrite(pins[i], LOW); // switching the LED at index i off 20 } 21 for (int i=pinsCount-1; i>0; i=i-1){ // chasing left (except the outer leds) 22 digitalWrite(pins[i], HIGH); // switching the LED at index i on 23 delay(100); // stopping the program for 100 milliseconds 24 digitalWrite(pins[i], LOW); // switching the LED at index i off 25 } 26}
Downloadable files
Circuit Diagram
Circuit Diagram

Comments
Only logged in users can leave comments