If you want to control 16 led with 18 effects check out this link.
https://youtu.be/lv_L9VjdKYI
1. To build led chaser we need a breadboard to create a connection between a component.
2. we need 12 resistors of 220 ohms each and 12 LEDs of the same color or a different color.
3. Attach all LEDs to the breadboard in parallel form.
4. After the led is attached, now connect the resistor to the positive pin of all LEDs.
5. Now connect the end of the resistors to pin 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12, 13 of the Arduino using a jumper wire.
6. Connect the negative pin of all LEDs to the GND pin of Arduino using a jumper wire.
7. Now the circuit is ready to upload the code through Arduino Uno.
Your LED chaser is ready.....enjoy it......😍😍😍😍😍😍😍😍
Components Required:-
1 × Arduino board.
1 × Breadboard.
12 × 5mm Led.
12 × Resistor (220Ω).
12 × Jumper wires (M).
Circuit diagram:-
Arduino basic effect code:-
//initializing a variable for digital pin 2 to 13
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;
int led9 = 10;
int led10 = 11;
int led11 = 12;
int led12 = 13;
void setup() {
// put your setup code here, to run once:
//initialize digital pin as output
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(led11, OUTPUT);
pinMode(led12, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led1, HIGH);//it mean to give 5v(high) to pins.here ,the led will be on.
delay(1000);//1000 = 1 second
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led4, HIGH);
delay(1000);
digitalWrite(led5, HIGH);
delay(1000);
digitalWrite(led6, HIGH);
delay(1000);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led8, HIGH);
delay(1000);
digitalWrite(led9, HIGH);
delay(1000);
digitalWrite(led10, HIGH);
delay(1000);
digitalWrite(led11, HIGH);
delay(1000);
digitalWrite(led12, HIGH);
delay(1000);
digitalWrite(led1, LOW);//it mean to give 0v(low) to pin.here, led will be off
delay(1000);
digitalWrite(led2, LOW);
delay(1000);
digitalWrite(led3, LOW);
delay(1000);
digitalWrite(led4, LOW);
delay(1000);
digitalWrite(led5, LOW);
delay(1000);
digitalWrite(led6, LOW);
delay(1000);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led8, LOW);
delay(1000);
digitalWrite(led9, LOW);
delay(1000);
digitalWrite(led10, LOW);
delay(1000);
digitalWrite(led11, LOW);
delay(1000);
digitalWrite(led12, LOW);
delay(1000);
}
Arduino 7 Effect code:-
#define t 30
#define t1 20
#define t2 100
#define t3 50
void setup() {
// set up pins 2 to 13 as outputs
for (int i = 2; i <= 13; i++) {
pinMode(i, OUTPUT);
}
}
/////////////////////////////////////////////////////////////////////////////////Effect 1
void loop(){
effect_1();
effect_1();
effect_2();
effect_2();
effect_3();
effect_3();
effect_4();
effect_4();
effect_5();
effect_5();
effect_6();
effect_6();
effect_7();
effect_7();
}
//left to right and right to left
void effect_1()
{
for(int i=2; i<14; i++){
digitalWrite(i, HIGH);
delay(t1);
digitalWrite(i+1, HIGH);
delay(t1);
digitalWrite(i+2, HIGH);
delay(t1);
digitalWrite(i, LOW);
delay(t1);
digitalWrite(i+1, LOW);
delay(t1);
}
for(int i=13; i>1; i--){
digitalWrite(i, HIGH);
delay(t1);
digitalWrite(i-1, HIGH);
delay(t1);
digitalWrite(i-2, HIGH);
delay(t1);
digitalWrite(i, LOW);
delay(t1);
digitalWrite(i-1, LOW);
delay(t1);
}
}
/////////////////////////////////////////////////////////////////////////////////Effect 2
void effect_2()
{
int count = 13; // keeps track of second LED movement
// move first LED from left to right and second from right to left
for (int i = 2; i < 13; i++) {
clear();
digitalWrite(i, HIGH); // chaser 1
digitalWrite(count, HIGH); // chaser 2
count--;
// stop LEDs from appearing to stand still in the middle
if (count != 7) {
delay(t2);
}
}
// move first LED from right to left and second LED from left to right
for (int i = 13; i > 2; i--) {
clear();
digitalWrite(i, HIGH); // chaser 1
digitalWrite(count, HIGH); // chaser 2
count++;
// stop LEDs from appearing to stand still in the middle
if (count != 8) {
delay(t2);
}
}
}
////////////////////////////////////////////////////////////////////////////////Effect 3
void effect_3()
{
for(int i=2; i<14; i++){
digitalWrite(i, HIGH);
delay(t3);
}
for(int i=2; i<14; i++){
digitalWrite(i, LOW);
delay(t3);
}
for(int i = 14; i>=2; i--){
digitalWrite(i, HIGH);
delay(t3);
}
for(int i = 14; i>=2; i--){
digitalWrite(i, LOW);
delay(t3);
}
}
///////////////////////////////////////////////////////////////////////////Effect 4
void effect_4()
{
for(int j = 2; j <= 13; j++){
digitalWrite(j, HIGH);
delay(t2);
j=j+1;
}
for(int j = 2; j <= 13; j++){
digitalWrite(j, LOW);
delay(t2);
}
for(int k = 15; k > 2; k--){
digitalWrite(k, HIGH);
delay(t2);
k=k-1;
}
for(int k = 15; k > 2; k--){
digitalWrite(k, LOW);
delay(t2);
}
}
//////////////////////////////////////////////////////////////////////////////Effect 5
void effect_5()
{
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin, HIGH);
delay(t1);
digitalWrite(pin+1, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+1, HIGH);
delay(t1);
digitalWrite(pin+2, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+2, HIGH);
delay(t1);
digitalWrite(pin+3, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+3, HIGH);
delay(t1);
digitalWrite(pin+4, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+4, HIGH);
delay(t1);
digitalWrite(pin+5, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+5, HIGH);
delay(t1);
digitalWrite(pin+6, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+6, HIGH);
delay(t1);
digitalWrite(pin+7, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+7, HIGH);
delay(t1);
digitalWrite(pin+8, LOW);
delay(t1);
}
for(int pin = 9; pin >= 2; pin--)
{
digitalWrite(pin+8, HIGH);
delay(t1);
digitalWrite(pin+9, LOW);
delay(t1);
}
for(int pin = 9; pin >= 2; pin--)
{
digitalWrite(pin+9, HIGH);
delay(t1);
digitalWrite(pin+10, LOW);
delay(t1);
}
for(int pin = 9; pin >= 2; pin--)
{
digitalWrite(pin+10, HIGH);
delay(t1);
digitalWrite(pin+11, LOW);
delay(t1);
}
for(int pin = 14; pin >= 2; pin--)
{
digitalWrite(pin+11, HIGH);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin, LOW);
delay(t1);
}
}
/////////////////////////////////////////////////////////////////////////////Effect 6
void effect_6()
{
for(int j=2; j<14; j++){
digitalWrite(j, LOW);
delay(t);
digitalWrite(j, HIGH);
delay(t);
digitalWrite(j-2, LOW);
delay(t);
digitalWrite(j, HIGH);
}
for(int k = 15; k>2; k--){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k+2, LOW);
delay(t);
digitalWrite(k, HIGH);
}
for(int k = 2; k<14; k++){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k-2, LOW);
delay(t);
digitalWrite(k, HIGH);
}
for(int k = 15; k>2; k--){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k+4, LOW);
delay(t);
digitalWrite(k, HIGH);
}
for(int k = 2; k<14; k++){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k-4, LOW);
delay(t);
digitalWrite(k, HIGH);
}
}
///////////////////////////////////////////////////////////////////////////////////Effect 7
void effect_7()
{
for(int j=2; j<14; j++){
digitalWrite(j, HIGH);
delay(t);
digitalWrite(j+2, LOW);
delay(t);
}
for(int k = 15; k>2; k--){
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k+2, LOW);
delay(t);
}
}
// function to switch all LEDs off
void clear(void)
{
for (int i = 2; i <= 13; i++) {
digitalWrite(i, LOW);
}
}
//initializing a variable for digital pin 2 to 13
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;
int led9 = 10;
int led10 = 11;
int led11 = 12;
int led12 = 13;
void setup() {
// put your setup code here, to run once:
//initialize digital pin as output
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(led11, OUTPUT);
pinMode(led12, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led1, HIGH);//it mean to give 5v(high) to pins.here ,the led will be on.
delay(1000);//1000 = 1 second
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led4, HIGH);
delay(1000);
digitalWrite(led5, HIGH);
delay(1000);
digitalWrite(led6, HIGH);
delay(1000);
digitalWrite(led7, HIGH);
delay(1000);
digitalWrite(led8, HIGH);
delay(1000);
digitalWrite(led9, HIGH);
delay(1000);
digitalWrite(led10, HIGH);
delay(1000);
digitalWrite(led11, HIGH);
delay(1000);
digitalWrite(led12, HIGH);
delay(1000);
digitalWrite(led1, LOW);//it mean to give 0v(low) to pin.here, led will be off
delay(1000);
digitalWrite(led2, LOW);
delay(1000);
digitalWrite(led3, LOW);
delay(1000);
digitalWrite(led4, LOW);
delay(1000);
digitalWrite(led5, LOW);
delay(1000);
digitalWrite(led6, LOW);
delay(1000);
digitalWrite(led7, LOW);
delay(1000);
digitalWrite(led8, LOW);
delay(1000);
digitalWrite(led9, LOW);
delay(1000);
digitalWrite(led10, LOW);
delay(1000);
digitalWrite(led11, LOW);
delay(1000);
digitalWrite(led12, LOW);
delay(1000);
}
Arduino 7 Effect code:-
#define t 30
#define t1 20
#define t2 100
#define t3 50
void setup() {
// set up pins 2 to 13 as outputs
for (int i = 2; i <= 13; i++) {
pinMode(i, OUTPUT);
}
}
/////////////////////////////////////////////////////////////////////////////////Effect 1
void loop(){
effect_1();
effect_1();
effect_2();
effect_2();
effect_3();
effect_3();
effect_4();
effect_4();
effect_5();
effect_5();
effect_6();
effect_6();
effect_7();
effect_7();
}
//left to right and right to left
void effect_1()
{
for(int i=2; i<14; i++){
digitalWrite(i, HIGH);
delay(t1);
digitalWrite(i+1, HIGH);
delay(t1);
digitalWrite(i+2, HIGH);
delay(t1);
digitalWrite(i, LOW);
delay(t1);
digitalWrite(i+1, LOW);
delay(t1);
}
for(int i=13; i>1; i--){
digitalWrite(i, HIGH);
delay(t1);
digitalWrite(i-1, HIGH);
delay(t1);
digitalWrite(i-2, HIGH);
delay(t1);
digitalWrite(i, LOW);
delay(t1);
digitalWrite(i-1, LOW);
delay(t1);
}
}
/////////////////////////////////////////////////////////////////////////////////Effect 2
void effect_2()
{
int count = 13; // keeps track of second LED movement
// move first LED from left to right and second from right to left
for (int i = 2; i < 13; i++) {
clear();
digitalWrite(i, HIGH); // chaser 1
digitalWrite(count, HIGH); // chaser 2
count--;
// stop LEDs from appearing to stand still in the middle
if (count != 7) {
delay(t2);
}
}
// move first LED from right to left and second LED from left to right
for (int i = 13; i > 2; i--) {
clear();
digitalWrite(i, HIGH); // chaser 1
digitalWrite(count, HIGH); // chaser 2
count++;
// stop LEDs from appearing to stand still in the middle
if (count != 8) {
delay(t2);
}
}
}
////////////////////////////////////////////////////////////////////////////////Effect 3
void effect_3()
{
for(int i=2; i<14; i++){
digitalWrite(i, HIGH);
delay(t3);
}
for(int i=2; i<14; i++){
digitalWrite(i, LOW);
delay(t3);
}
for(int i = 14; i>=2; i--){
digitalWrite(i, HIGH);
delay(t3);
}
for(int i = 14; i>=2; i--){
digitalWrite(i, LOW);
delay(t3);
}
}
///////////////////////////////////////////////////////////////////////////Effect 4
void effect_4()
{
for(int j = 2; j <= 13; j++){
digitalWrite(j, HIGH);
delay(t2);
j=j+1;
}
for(int j = 2; j <= 13; j++){
digitalWrite(j, LOW);
delay(t2);
}
for(int k = 15; k > 2; k--){
digitalWrite(k, HIGH);
delay(t2);
k=k-1;
}
for(int k = 15; k > 2; k--){
digitalWrite(k, LOW);
delay(t2);
}
}
//////////////////////////////////////////////////////////////////////////////Effect 5
void effect_5()
{
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin, HIGH);
delay(t1);
digitalWrite(pin+1, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+1, HIGH);
delay(t1);
digitalWrite(pin+2, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+2, HIGH);
delay(t1);
digitalWrite(pin+3, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+3, HIGH);
delay(t1);
digitalWrite(pin+4, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+4, HIGH);
delay(t1);
digitalWrite(pin+5, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+5, HIGH);
delay(t1);
digitalWrite(pin+6, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+6, HIGH);
delay(t1);
digitalWrite(pin+7, LOW);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin+7, HIGH);
delay(t1);
digitalWrite(pin+8, LOW);
delay(t1);
}
for(int pin = 9; pin >= 2; pin--)
{
digitalWrite(pin+8, HIGH);
delay(t1);
digitalWrite(pin+9, LOW);
delay(t1);
}
for(int pin = 9; pin >= 2; pin--)
{
digitalWrite(pin+9, HIGH);
delay(t1);
digitalWrite(pin+10, LOW);
delay(t1);
}
for(int pin = 9; pin >= 2; pin--)
{
digitalWrite(pin+10, HIGH);
delay(t1);
digitalWrite(pin+11, LOW);
delay(t1);
}
for(int pin = 14; pin >= 2; pin--)
{
digitalWrite(pin+11, HIGH);
delay(t1);
}
for(int pin = 13; pin >= 2; pin--)
{
digitalWrite(pin, LOW);
delay(t1);
}
}
/////////////////////////////////////////////////////////////////////////////Effect 6
void effect_6()
{
for(int j=2; j<14; j++){
digitalWrite(j, LOW);
delay(t);
digitalWrite(j, HIGH);
delay(t);
digitalWrite(j-2, LOW);
delay(t);
digitalWrite(j, HIGH);
}
for(int k = 15; k>2; k--){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k+2, LOW);
delay(t);
digitalWrite(k, HIGH);
}
for(int k = 2; k<14; k++){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k-2, LOW);
delay(t);
digitalWrite(k, HIGH);
}
for(int k = 15; k>2; k--){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k+4, LOW);
delay(t);
digitalWrite(k, HIGH);
}
for(int k = 2; k<14; k++){
digitalWrite(k, LOW);
delay(t);
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k-4, LOW);
delay(t);
digitalWrite(k, HIGH);
}
}
///////////////////////////////////////////////////////////////////////////////////Effect 7
void effect_7()
{
for(int j=2; j<14; j++){
digitalWrite(j, HIGH);
delay(t);
digitalWrite(j+2, LOW);
delay(t);
}
for(int k = 15; k>2; k--){
digitalWrite(k, HIGH);
delay(t);
digitalWrite(k+2, LOW);
delay(t);
}
}
// function to switch all LEDs off
void clear(void)
{
for (int i = 2; i <= 13; i++) {
digitalWrite(i, LOW);
}
}
Watch this video
Which code we paste. here are basic and 7effect
ReplyDelete7 Effect code bro...
Deleteawesome project, 5th effect not working properly, when 6th pin o/p glow, first and second o/p blinking, please rectify the issue
ReplyDeleteYes,same with me
DeleteI updated the code. Check it and also don't forget to my channel
ReplyDeleteMr.ElectroUino
Hello Mr ElectroUino Thank you for the nice and working project. I liked it I created an instructable for the same here. I have used Wokwi Arduino simulator 🙂
ReplyDeletehttps://www.instructables.com/LED-Chaser-With-7-Patterns-wokwi-Arduino/
If you have any thing to ask, please feel free to leave a comment. I have mentioned your site as well in the instructables so that the readers can find your site 😀
i cant get the code work; void setup() {
ReplyDelete// set up pins 2 to 13 as outputs
for (int i = 2; i <= 13; i++) {
pinMode(i, OUTPUT);
this is not letting me download please help thanks
I want to setup stair case light..please help me
ReplyDeleteAm using 12 V led light strip
I need 200 mili amp per stair..please suggest me the mosfet and register circuit diagram.
arupbiswas1994@gmail.com
Visit this for that
Deletehttps://mrelectrouino.blogspot.com/2021/01/arduino-control-12v-led-with-tip120.html
Cant i coppy the codes nd paste in ardino library sir i am a new user 4 aurdino
ReplyDeleteI don't care
DeleteHey man, firstly thanks for this tutorial! It's really helpful starting out with Arduino.
ReplyDeleteOne problem i'm getting is with the clear(); while writing effect_2
I get this message when verifying - "Clear" was not defined in this scope
Do you know why i would be getting this?
Bikes and bicycles can get as much light from one LED as from both car headlights. The latest LED light design helps you see better in the dark, improves visibility, and acts as a shield for you in the dark.
ReplyDeleteWith LED lights woven into the spokes, your bike will look stylish. To add a dazzling effect to your driving, having Bike Wheel Lights on your bike or bicycle is a great benefit.