Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
KaveeshaB
Published © LGPL

Create Knight Rider Circuit Using Arduino MEGA 2560

This is a simple circuit consisting of 10 LED lights that creates a cool running LED effect.

BeginnerFull instructions provided2,011
Create Knight Rider Circuit Using Arduino MEGA 2560

Things used in this project

Hardware components

5 mm LED: Red
5 mm LED: Red
×10
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Arduino Mega 2560
Arduino Mega 2560
×1

Story

Read more

Schematics

Circuit

Code

Source Code

Arduino
int i;
void setup(){
  // put your setup code here, to run once:
        for(i=1;i<12;i++){
             pinMode(i,OUTPUT);  // define pinMode
        }    
}

void loop() {
  // put your main code here, to run repeatedly:
        for(i=1;i<9;i++){
            digitalWrite(i,1);
            digitalWrite(i+1,1);
           digitalWrite(i+2,1);
           digitalWrite(i+3,1);
           digitalWrite(i,0);
           delay(100);  
        }
  
       for(i=11;i>5;i--){
  
          digitalWrite(i,1);
          digitalWrite(i-1,1);
          digitalWrite(i-2,1);
          digitalWrite(i-3,1);
          digitalWrite(i,0);
         delay(100);
    
        }  
}

Credits

KaveeshaB
1 project • 0 followers

Comments