Simple LED light chaser

In this tutorial, you will learn how to make a simple light chaser, which will consist of only 3 LEDs. What does a lightchaser do? A light chaser can be used to create lighting animation sequences to attract attention.

Overview

light_chaser

Basically, to make the light chaser, you will have to turn on one LED at a time while the rest of the LED is off. The process/program should be like this:

  • 1st LED is ON, 2nd & 3rd LED off
  • 2nd LED is ON, 1st & 3rd LED off
  • 3rd LED is ON, 1st & 2nd LED off
  • Go back to line 1

But, how do we do this? Well, the solution will be to use a for() loop function!

A for() loop function will be used to repeat the block of code which will turn ON & OFF the LED. The variable, i, will be used in this loop to determined & keep track which LED will be turned on. At every end in the for() loop, variable i will be incremented by one, which will caused the next LED to be turned ON. As there is only 3 LEDs used in this tutorial, I will only need to repeat the loop 3 times, and hence the condition of the for() loop will be i < 3. Now you may ask, how do I actually tell the Arduino which LED to turn on and which to turn off? Well, we will use a array to store the LED pins, which will be called “ledPin[]”. We will be using the digital pins 9 ,10 , 11 for this tutorial, and this values will be stored in ledPin[].

The potentiometer will be used to determine the delay of each LED, which turning anti-clockwise will make the delay shorter. The values of the potentiometer will be mapped from a range of 0 – 1023 to a range of 10 – 500, as this will determine the delay between each LED.

 

Parts

  • Arduino Uno Board x 1
  • Green LEDs x 3
  • 330Ω Resistors x 3
  • Jumper Wires x 7
  • Potentiometer x 1
  • Breadboard (Any size will do)

 

Demo

 

Code

The code below is slightly differrent from the one you see in the video. This code is much more optimised & shorter.

 

Going further

Want to challenge yourself? Here are some things you can try out:

  • Make a 12 LED light chaser
  • Make a fading LED light chaser (or “LED rain” light chaser)
  • Make a RGB LED light chaser

 

Useful links:

Share this post:

You may also like...

Leave a Reply