You are on page 1of 3

LED Chaser using Arduino

This is a LED Chaser, with the simplest code. Here you vary the
speed of chasing LEDs by potentiometer which is as analog input
to arduino.You can have different LED glowing arrangements, like
Knight Rider is kinda famous, you can make it by simply putting
the same loop but with descending outputs try it.

The potentiometer has three pins, the centre one is connected to


the analog input of arduino and rest of two pins are GND and Vcc
In the picture, the blue lead is going to 5v of Arduino, red lead is
connected to GND and Orange lead is connected to analog input
of arduino, (Here A0).Here I have used the potentiometer of
100k, However it does not matter, because in programming we
set the value ranging from 0-255

Connections with Bread board:


Arduino has two GND pins one is
along with power pins and other one is along with digital pins. Both of the
GND pins are common, so you may connect the GND pin of potentiometer
to either one
The programming code is actually not the proper one, It should
be done with bunch of nested for loops which is quite
complicated, this is what you are here for, things in easier way,
rookieelectronics.com
I found some on google and they had so many for loops and stuff. But
this is a ROOKIE code :p just to Turn On and Off LEDs in loop in a
sequence. You can select any outputs right now i have selected 8-12, you
can use all output pins from 1-13 and have 13 LEDs and have a longer
LED chaser
CODE:
int delayTime = 0;
void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() //this means Perform functions again and again
{
delayTime = analogRead(0); //0 means Analog Input A0
digitalWrite(8, HIGH); delay(delayTime);
digitalWrite(8, LOW); delay(delayTime);
digitalWrite(9, HIGH); delay(delayTime);
digitalWrite(9, LOW); delay(delayTime);
digitalWrite(10, HIGH); delay(delayTime);
digitalWrite(10, LOW); delay(delayTime);
digitalWrite(11, HIGH); delay(delayTime);
digitalWrite(11, LOW); delay(delayTime);
digitalWrite(12, HIGH); delay(delayTime);
digitalWrite(12, LOW); delay(delayTime);
}

You might also like