Devices & Components
Arduino Uno Rev3
Resistor 220 ohm
Jumper wires (generic)
Breadboard (generic)
LED (generic)
Hardware & Tools
Plier, Needle Nose
Software & Tools
Arduino IDE
Project description
Code
Code for this project
arduino
1//YouTube channel: https://www.youtube.com/channel/UC5trxvQIeT6XOJKarnHC5Eg?view_as=subscriber// 2//Instagram: https://www.instagram.com/royba71/ // 3//Project Roy Ben Avraham, Last modification 1/4/2020 // 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 17 for (int i=pinsCount-1; i>0; i=i-1){ // chasing left (except the outer leds) 18 digitalWrite(pins[i], HIGH); // switching the LED at index i on 19 delay(35); // stopping the program for 100 milliseconds 20 digitalWrite(pins[i], LOW); // switching the LED at index i off 21 } 22 for (int i=0; i<pinsCount; i=i+1){ // chasing right 23 digitalWrite(pins[i], HIGH); // switching the LED at index i on 24 delay(35); // stopping the program for 100 milliseconds 25 digitalWrite(pins[i], LOW); // switching the LED at index i off 26 } 27} 28 29//Good luck and enjoy, Roy. 30
Downloadable files
Diagram
Diagram

Diagram
Diagram

Comments
Only logged in users can leave comments