View on GitHub

Kerala-IoT-Challenge

Experiment 3 : LED Chasing Effect

Description :

In this experiment we create a program to simulate LED chasing effect

Components Used :

Circuit :

Connections are made according to the Circuit given
Expriment 3

Code :

#define BASE 2 //define pin 2 as I/O for first LED
#define NUM 6 // number of LEDs
void setup()
{
  for(int i = BASE;i < BASE + NUM;i++)
  {
    pinMode(i, OUTPUT); //set I/O pins as Output
  }
}
void loop()
{
  for(int i = BASE;i < BASE + NUM;i++)
  {
    digitalWrite(i, LOW); //turn off LEDs 1 by 1
    delay(200); //wait for 0.2 second
  }
  for(int i = BASE;i < BASE + NUM;i++)
  {
    digitalWrite(i, HIGH); //turn on LEDs 1 by 1
    delay(200); //wait for 0.2 second
  }
}

Video :

The output of this experiment would be like this :