Call Us Now
0242159130 | 0546096840
Up to 2% reward

For new all Customers

Delevery schedule

We deliver  the same day through VIP bus parcel Service in Ghana

Discount on order gift

Save ¢10.00 when you spend ¢600+! 

how to flowing LED Lights

how to flowing LED Lights

Experimental 6

In this lesson, we will program the Arduino UNO to make an LED flowing blink by sequence from the red one on the right side to others on the left.

Hardware Required

1 * Arduino UNO

1 * USB Cable

8 * LED

8 * 220Ω Resistor

1 * Breadboard

Several jumper wires 


Principle of operation

The principle of this experiment is very simple and is quite similar with that in the first lesson. K e y f u n c ti o n : ●for statements The for statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop.The for statement is use ful for any repetitive operation,and is often used in combination with arrays to operate on collections of data/pins. There are three parts to the for loop header: for (initialization; condition; increment) { //statement(s); }

The initialization happens first and exactly once. Each time through the loop, the condition is tested; if it's true, the statement block, and the increment is executed, then the condition is tested again. When the condition becomes false, the loop ends. 

Experimental code

//File name:   Experiment 1

//Description:  flowing LED .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08 


void setup()

  unsigned char ledPin;           //ledPin will be set to 1,2,3,4,5,6, 7 and 8.

  for(ledPin=1;ledPin<=8;ledPin++)//In turn set 1 ~ 8 digital pins to output mode 

  pinMode(ledPin,OUTPUT);         //Set the  ledPin pin to output mode 

}


void loop()

{   

  unsigned char ledPin;           //ledPin will be set to 1,2,3,4,5,6, 7 and 8.

  for(ledPin=1;ledPin<=8;ledPin++)//Every 200ms on in order LED1 ~ 8 

  {

    digitalWrite(ledPin,HIGH);    //led on

    delay(200);                   //Delay 200 ms

  }

  for(ledPin=1;ledPin<=8;ledPin++)//Every 200ms off in order LED1 ~ 8 

  {

    digitalWrite(ledPin,LOW);     //led off

    delay(200);                   //Delay 200 ms

  } 

}

Compile the program and upload to Arduino UNO board Now,you can see 8 LEDs light up in sequence from the red one on the right side to others on the left, and next from the left to the right.The LEDs flash like flowing water repeatedly in a circular way

Add Comment