Maker Pro
Arduino

Scrolling LEDs

September 01, 2020 by siraj pathan
Share
banner

This is a very useful project for beginners. It helps with understanding the workings of a delay programmer.

Connect all the LEDs and resistors to the breadboard

connect the arduino uno to your PC.

Read the code, understand it (you can change the delay time and the order of the scrolling) and upload it to your board.

// Your code here

int pinsCount=10;                        // declaring the integer variable pinsCount
int pins[] = {2,3,4,5,6,7,8,9,10,11};          // declaring the array pins[]
 
void setup() {                
  for (int i=0; i<pinsCount; i=i+1){    // counting the variable i from 0 to 9
    pinMode(pins[i], OUTPUT);            // initialising the pin at index i of the array of pins as OUTPUT
  }
}
 
void loop() {
  
  for (int i=pinsCount-1; i>0; i=i-1){   // chasing left (except the outer leds)
    digitalWrite(pins[i], HIGH);         // switching the LED at index i on
    delay(35);                          // stopping the program for 100 milliseconds
    digitalWrite(pins[i], LOW);          // switching the LED at index i off
  }
   for (int i=0; i<pinsCount; i=i+1){    // chasing right
    digitalWrite(pins[i], HIGH);         // switching the LED at index i on
    delay(35);                          // stopping the program for 100 milliseconds
    digitalWrite(pins[i], LOW);          // switching the LED at index i off
  }
}

Author

Avatar
siraj pathan

11 years of Experience as Assistant Professor in Mumbai University,Interested in Analog , Digital Circuit ,Arduino , Rasberrypi, IoT , PCB Design

Related Content

Comments


You May Also Like