Knight Rider Circuit

10.0K51333

Intro: 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.

22 Comments

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

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?

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!)

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.

Link Doesn't work thankx for the comment

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

Steve

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.

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

More Comments