Knight Rider Circuit

5,332

504

21

Published

Introduction: Knight Rider Circuit

This time its not a big project. Its just a simple circuit that uses a arduino uno, 9 Red LEDs , a Resistor, few jumpers and a breadboard to make the LEDs act like the LED panel in the michael's car.

Step 1: Things Needed+

Here the Things Needed for this project.

  1. 9 Red LEDs.
  2. A 220 Ohm Resistor.
  3. Mini Bread board.
  4. Jumpers.
  5. Arduino Uno with the cable.

Step 2: LEDs + Resistor

First of all fix the LEDs and the resistor as shown.

Step 3: Connections+

Remember to start from the pins above 1. You can use them but it may occur some problems while uploading to the board. Make sure to carefully observe the circuit diagram.

Step 4: Programing........

I am not going to explain far about the code. Simply Its programmed to Turn one led on then wait about 40 milliseconds and then trun on the other one. And It will go again and again.

Heres the code.

int pin2 = 2;
int pin3 = 3; int pin4 = 4; int pin5 = 5; int pin6 = 6; int pin7 = 7; int pin8 = 8; int pin9 = 9; int pin10 = 10; int timer = 40;

void setup(){ pinMode(pin2, OUTPUT); pinMode(pin3, OUTPUT); pinMode(pin4, OUTPUT); pinMode(pin5, OUTPUT); pinMode(pin6, OUTPUT); pinMode(pin7, OUTPUT); pinMode(pin8, OUTPUT); pinMode(pin9, OUTPUT); pinMode(pin10, OUTPUT); }

void loop() { digitalWrite(pin2, HIGH); delay(timer); digitalWrite(pin2, LOW); delay(timer);

digitalWrite(pin3, HIGH); delay(timer); digitalWrite(pin3, LOW); delay(timer);

digitalWrite(pin4, HIGH); delay(timer); digitalWrite(pin4, LOW); delay(timer);

digitalWrite(pin5, HIGH); delay(timer); digitalWrite(pin5, LOW); delay(timer);

digitalWrite(pin6, HIGH); delay(timer); digitalWrite(pin6, LOW); delay(timer);

digitalWrite(pin7, HIGH); delay(timer); digitalWrite(pin7, LOW); delay(timer); digitalWrite(pin8, HIGH); delay(timer); digitalWrite(pin8, LOW); delay(timer);

digitalWrite(pin9, HIGH); delay(timer); digitalWrite(pin9, LOW); delay(timer); digitalWrite(pin10, HIGH); delay(timer); digitalWrite(pin10, LOW); delay(timer); digitalWrite(pin10, HIGH); delay(timer); digitalWrite(pin10, LOW); delay(timer); digitalWrite(pin9, HIGH); delay(timer); digitalWrite(pin9, LOW); delay(timer); digitalWrite(pin8, HIGH); delay(timer); digitalWrite(pin8, LOW); delay(timer); digitalWrite(pin7, HIGH); delay(timer); digitalWrite(pin7, LOW); delay(timer); digitalWrite(pin6, HIGH); delay(timer); digitalWrite(pin6, LOW); delay(timer);

digitalWrite(pin5, HIGH); delay(timer); digitalWrite(pin5, LOW); delay(timer);

digitalWrite(pin4, HIGH); delay(timer); digitalWrite(pin4, LOW); delay(timer);

digitalWrite(pin3, HIGH); delay(timer); digitalWrite(pin3, LOW); delay(timer); }

Step 5: And Done!

And we done I wish you a good luck on trying this circuit. And if you like this project please make sure to vote me in the contests in instructables.

Share

    Recommendations

    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Oil Contest

      Oil Contest

    21 Discussions

    Take a look at the For loop function, it would significantly reduce your code.

    3 replies

    JakubK27, you are correct with one exception. You should have said

    uppercase(" significantly").

    Nice Job Kinte Ryder, the important thing is it gets the J O B done - whether in 39 bytes or 390 bytes. Tim

    It would be:

    No longer a mess of repeated strings.

    Easier to add other features, like adding more LEDs.

    Easier to change stuff.

    Probably quicker to write.

    And, I didn't mean it as an issue with the code, as you said, it works. I meant as a way to improve the programming skills of the writer / exercise for the other readers trying to learn programming. For loop is a really amazing tool, great for more advanced projects.

    Have you tried to sync up the music with it in arduino?

    1 reply

    Great idea, well done

    A little point that you can all try

    Instead of: int pin2 = 2; etc, etc ...

    use: const int pin2 = 2; etc, etc ...

    The 'const int' way, makes sure that the variable (in this case) pin2 is unchangeable by the program. Somewhat like a #DEFINE (but with less downfalls!)

    1 reply

    Very nice. Hers's a little something to get your creative juices flowing. There are 7 patterns: sequential, wigwag, center_out_back, marquee, wigwag_even-odd,
    center_out and all_wig_wag. Each pattern runs until a timer times out, then the pattern switches to the next one. After the last pattern runs, it returns to the first. I'll send you the code if you're interested. The vid is MP4. let me know if that doesn't work for you.

    1 reply

    Link Doesn't work thankx for the comment

    Loops are your friend, buddy! "I can't let you do that Michael"

    Steve

    1 reply
    0
    user
    gm280

    6 months ago

    Not familiar with the syntax of the Arduino code, being I have never ever programmed one, where is "timer" described in the code? I see you calling that function both for the LED on,and LED off times, and was wondering if that was an internal function or you made a call to a subroutine you wrote. And how much time does it wait? I have programmed so many other Microprocessors and Controllers before, but not yet an Arduino.

    4 replies

    top of the code, it's a variable that's being set.

    int timer = 40;

    Oh my, I some how over looked it. Sorry, but that makes a lot more sense to me now. Thanks for pointing that out. Also a great idea so if you want to lengthen the time delay, you do it in one place.

    Its looked like I was late to help but anyway thankx for commenting