edge lab LIVE! starts Tuesday in Munich. Grab a workshop seat and take home the board you build on. Code FRIEND-HACKSTER saves 20%. () Learn more!
jomar
Published © CC BY-NC

Sequential LED Lighting

A sequential LED lights that come and go.

BeginnerFull instructions provided9,096
Sequential LED Lighting

Things used in this project

Hardware components

Arduino Mega
×1
Resistor 221 ohm
Resistor 221 ohm
×8
LED (generic)
LED (generic)
×8
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Protoboard schematic

In this image we have how to link the wires, resistors, LEDS to the arduino board.

Esquema

Code

Sequential LEDS

Arduino
just open on your IDE Arduino
/* SEQUENTIAL LEDS
 * by Jomar B Amaral
 * [email protected] for more information
 * with small modifications on this code many different sequences are possible
 */

int ledPin[] = {38, 40, 42, 44, 46, 48, 50, 52}; //pins used, you can modify to you arduino board
int i = 38; //you can modify to you arduino board, i is the first pin your led is connected
int x = 52; //you can modify to you arduino board, x is the last pin your led is connected

void setup()
{
  for (int j=0; j<9; j++)
  {
   pinMode(ledPin[j], OUTPUT); // configura pino digital como sada
  }
}

void loop()
{
   for (i; i <= 52; i++)
    {
   digitalWrite(i,HIGH);
   delay(100);  // optional delay, in this case leds turn on one by one by 100 ms
    }
  {
    for (x; x >= 38; x--)
    {
    digitalWrite(x,LOW);
    delay(100);  //leds turn off one by one by 100 ms
    }
     {
      x=52; //optional
      i=38; //optional
      }
   }
}

Credits

jomar
1 project • 0 followers

Comments