How to Make Led Chaser With Arduino
by shashwat__raj in Circuits > Arduino
268 Views, 0 Favorites, 0 Comments
How to Make Led Chaser With Arduino
About Project
This is very interesting and easy project as in this project you only need Arduino Uno or Arduino Nano,
Leds of same colour or of different colours and some connecting wires.
You can connect almost 10 to 12 leds with arduino so that you get more interesting results for your
hard work.
This is very interesting and easy project as in this project you only need Arduino Uno or Arduino Nano,
Leds of same colour or of different colours and some connecting wires.
You can connect almost 10 to 12 leds with arduino so that you get more interesting results for your
hard work.
Material Required
1. Arduino Nano
2. Leds
3. Breadboard
4. Jumper wires
2. Leds
3. Breadboard
4. Jumper wires
Demo Video
Video link :- @https://youtu.be/Dy5ZitCoEEY
Please watch the complete video to know how it works……
And like, share, comments on this video if you are new subscribe to our channel and follow on Arduino
I hope you enjoyed my project.
Thanks!
Circuit Diagram
Use this diagram for making of this project.
Arduino Codes
Arduino codes for Led Chaser
In this project, there are 4 different codes for your led chaser upload code on your arduino one by one
for best results.
1.
#define t 30
#define t1 20
#define t2 100
#define t3 50
Void setup()
{
For (int I = 2; I <= 13; i++) {
pinMode(I, OUTPUT);
}
}
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();
}
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 = 15; pin >= 2; pin--)
{
digitalWrite(pin, HIGH);
delay(t1);
digitalWrite(pin+1, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+1, HIGH);
delay(t1);
digitalWrite(pin+2, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+2, HIGH);
delay(t1);
digitalWrite(pin+3, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+3, HIGH);
delay(t1);
digitalWrite(pin+4, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+4, HIGH);
delay(t1);
digitalWrite(pin+5, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+5, HIGH);
delay(t1);
digitalWrite(pin+6, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+6, HIGH);
delay(t1);
digitalWrite(pin+7, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+7, HIGH);
delay(t1);
digitalWrite(pin+8, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+8, HIGH);
delay(t1);
digitalWrite(pin+9, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+9, HIGH);
delay(t1);
digitalWrite(pin+10, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+10, HIGH);
delay(t1);
digitalWrite(pin+11, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+11, HIGH);
delay(t1);
digitalWrite(pin+12, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+12, HIGH);
delay(t1);
digitalWrite(pin+13, LOW);
delay(t1);
}for(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+13, HIGH);
delay(t1);
digitalWrite(pin, LOW);
}
}
/////////////////////////////////////////////////////////////////////////////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);
}
}
2.
#define SPEED_MS 100
Void setup() {
// set up pins 2 to 13 as outputs
For (int I = 2; I <= 13; i++) {
pinMode(I, OUTPUT);
}
}
Uint16_t chase2 = 13; // keeps track of second LED movement
Void loop() {
// move first LED from left to right and second from right to left
For (int I = 2; I < 13; i++) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2--;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 7) {
Delay(SPEED_MS);
}
}
// move first LED from right to left and second LED from left to right
For (int I = 13; I > 2; i--) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2++;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 8) {
Delay(SPEED_MS);
}
}
}
// function to switch all LEDs off
Void allLEDsOff(void)
{
For (int I = 2; I <= 13; i++) {
digitalWrite(I, LOW);
}
}
3.
void setup(){
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop(){
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(2,LOW);
delay(100);
digitalWrite(3,LOW);
delay(100);
digitalWrite(4,LOW);
delay(100);
digitalWrite(5,LOW);
delay(100);
digitalWrite(6,LOW);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(9,LOW);
delay(100);
digitalWrite(10,LOW);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(13,LOW);
delay(100);
digitalWrite(13,HIGH);
delay(100);
digitalWrite(2,HIGH);
delay(100);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(3,HIGH);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(4,HIGH);
delay(100);
digitalWrite(10,HIGH);
delay(100);
digitalWrite(5,HIGH);
delay(100);
digitalWrite(9,HIGH);
delay(100);
digitalWrite(6,HIGH);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(7,HIGH);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(10,LOW);
delay(100);
digitalWrite(9,LOW);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(6,LOW);
delay(100);
digitalWrite(5,LOW);
delay(100);
digitalWrite(4,LOW);
delay(100);
digitalWrite(3,LOW);
delay(100);
digitalWrite(2,LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
digitalWrite(2,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(3,LOW);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(4,LOW);
delay(100);
digitalWrite(10,LOW);
delay(100);
digitalWrite(5,LOW);
delay(100);
digitalWrite(9,LOW);
delay(100);
digitalWrite(6,LOW);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(13,LOW);
delay(100);
}
4.
#define SPEED_MS 200
Void setup() {
// set up pins 2 to 13 as outputs
For (int I = 2; I <= 13; i++) {
pinMode(I, OUTPUT);
}
}
Uint16_t chase2 = 13; // keeps track of second LED movement
Void loop() {
// move first LED from left to right and second from right to left
For (int I = 2; I < 13; i++) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2--;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 7) {
Delay(SPEED_MS);
}
}
// move first LED from right to left and second LED from left to right
For (int I = 13; I > 2; i--) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2++;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 8) {
Delay(SPEED_MS);
}
}
}
// function to switch all LEDs off
Void allLEDsOff(void)
{
For (int I = 2; I <= 13; i++) {
digitalWrite(I, LOW);
}
}
In this project, there are 4 different codes for your led chaser upload code on your arduino one by one
for best results.
1.
#define t 30
#define t1 20
#define t2 100
#define t3 50
Void setup()
{
For (int I = 2; I <= 13; i++) {
pinMode(I, OUTPUT);
}
}
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();
}
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 = 15; pin >= 2; pin--)
{
digitalWrite(pin, HIGH);
delay(t1);
digitalWrite(pin+1, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+1, HIGH);
delay(t1);
digitalWrite(pin+2, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+2, HIGH);
delay(t1);
digitalWrite(pin+3, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+3, HIGH);
delay(t1);
digitalWrite(pin+4, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+4, HIGH);
delay(t1);
digitalWrite(pin+5, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+5, HIGH);
delay(t1);
digitalWrite(pin+6, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+6, HIGH);
delay(t1);
digitalWrite(pin+7, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+7, HIGH);
delay(t1);
digitalWrite(pin+8, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+8, HIGH);
delay(t1);
digitalWrite(pin+9, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+9, HIGH);
delay(t1);
digitalWrite(pin+10, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+10, HIGH);
delay(t1);
digitalWrite(pin+11, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+11, HIGH);
delay(t1);
digitalWrite(pin+12, LOW);
delay(t1);
}
For(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+12, HIGH);
delay(t1);
digitalWrite(pin+13, LOW);
delay(t1);
}for(int pin = 15; pin >= 2; pin--)
{
digitalWrite(pin+13, HIGH);
delay(t1);
digitalWrite(pin, LOW);
}
}
/////////////////////////////////////////////////////////////////////////////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);
}
}
2.
#define SPEED_MS 100
Void setup() {
// set up pins 2 to 13 as outputs
For (int I = 2; I <= 13; i++) {
pinMode(I, OUTPUT);
}
}
Uint16_t chase2 = 13; // keeps track of second LED movement
Void loop() {
// move first LED from left to right and second from right to left
For (int I = 2; I < 13; i++) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2--;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 7) {
Delay(SPEED_MS);
}
}
// move first LED from right to left and second LED from left to right
For (int I = 13; I > 2; i--) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2++;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 8) {
Delay(SPEED_MS);
}
}
}
// function to switch all LEDs off
Void allLEDsOff(void)
{
For (int I = 2; I <= 13; i++) {
digitalWrite(I, LOW);
}
}
3.
void setup(){
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop(){
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(2,LOW);
delay(100);
digitalWrite(3,LOW);
delay(100);
digitalWrite(4,LOW);
delay(100);
digitalWrite(5,LOW);
delay(100);
digitalWrite(6,LOW);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(9,LOW);
delay(100);
digitalWrite(10,LOW);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(13,LOW);
delay(100);
digitalWrite(13,HIGH);
delay(100);
digitalWrite(2,HIGH);
delay(100);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(3,HIGH);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(4,HIGH);
delay(100);
digitalWrite(10,HIGH);
delay(100);
digitalWrite(5,HIGH);
delay(100);
digitalWrite(9,HIGH);
delay(100);
digitalWrite(6,HIGH);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(7,HIGH);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(10,LOW);
delay(100);
digitalWrite(9,LOW);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(6,LOW);
delay(100);
digitalWrite(5,LOW);
delay(100);
digitalWrite(4,LOW);
delay(100);
digitalWrite(3,LOW);
delay(100);
digitalWrite(2,LOW);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(6, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(3, HIGH);
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
digitalWrite(2,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(3,LOW);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(4,LOW);
delay(100);
digitalWrite(10,LOW);
delay(100);
digitalWrite(5,LOW);
delay(100);
digitalWrite(9,LOW);
delay(100);
digitalWrite(6,LOW);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(7,LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11,LOW);
delay(100);
digitalWrite(12,LOW);
delay(100);
digitalWrite(13,LOW);
delay(100);
}
4.
#define SPEED_MS 200
Void setup() {
// set up pins 2 to 13 as outputs
For (int I = 2; I <= 13; i++) {
pinMode(I, OUTPUT);
}
}
Uint16_t chase2 = 13; // keeps track of second LED movement
Void loop() {
// move first LED from left to right and second from right to left
For (int I = 2; I < 13; i++) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2--;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 7) {
Delay(SPEED_MS);
}
}
// move first LED from right to left and second LED from left to right
For (int I = 13; I > 2; i--) {
allLEDsOff();
digitalWrite(I, HIGH); // chaser 1
digitalWrite(chase2, HIGH); // chaser 2
chase2++;
// stop LEDs from appearing to stand still in the middle
If (chase2 != 8) {
Delay(SPEED_MS);
}
}
}
// function to switch all LEDs off
Void allLEDsOff(void)
{
For (int I = 2; I <= 13; i++) {
digitalWrite(I, LOW);
}
}