Instructables
Okay, so recently I thought of an idea... why not make a knight rider program, and if it works ... make it look good and also make it on a circuit board? So that's what I did. I made a effective program for arduino that will simulate the Cylon/Night Rider lights.
So basically I made a program and a circuit.
uhh... so keep reading!


Step 1: Get the parts.

For this project you will need..
- an arduino duemilanove (anything that is roughly the same (size, shape , pin layout, program support, etc.))
- the program (you can copy it from the text here, or if my link works)
- header connectors, that fit in any breadboard, arduino ,etc. (I got them @ frys)
- 5 red leds- at ~3V (I only had white 5mm) -------- Do not get the giant red "super bright" 1cm long leds.
They are too big and are less powerful, trust me I have them right here and the white ones in this instructable are much much better, and brighter.
- 220 ohm resistor (I used 330 ohm, close enough) ------ Actually 100 ohm ones are the best.
- a circuit board or peg board i used Radio Shack Dual PC board 276-148
- wire (maybe, i bent the pins of the leds, so I didnt need any)
- A computer that can program your arduino (duh!)
- Solder + Iron
Okay so lets build it!

Step 2: Make the circut

Picture of Make the circut
Okay because this is a easy project you dont need a breadboard, the circuit is simple. We will start by connecting all 5 led's negative terminals together, and soldering it up (on the board), and connecting a 220 ohm resistor to the negative terminal of the leds, and the other end to the pin to go to ground of the arduino, and then your leds are connecting to pins 12, 11, 10, 9, and 8 (this will all follow my program). This circuit will save your resistors for you instead of using 5 of them.

Make your circuit based on the picture, and if you can similar to mine.

Gee, don't those pictures look alike?
Hmm....
 
Remove these adsRemove these ads by Signing Up
Klaudiuszm1 year ago
Nice instructable, although isn't the code a bit long? I wrote the code for the same function except its shorter.

int led = 8;
int time = 50;

void setup() {
  for(led = 8; led < 13; led++) { //declares the pins 8 - 12 as output pins
    pinMode(led, OUTPUT);
  }
}

void loop() {
  for(led = 8; led < 13; led++) { //Main: function starts at pin 8, turns led on, waits 50ms, turns them off, waits 50ms, repeats same function for next led until it hits pin 13 (pin 13 is not part of the function) and starts at pin 8
    digitalWrite(led, HIGH); //led on
    delay(time); //wait
    digitalWrite(led, LOW); //led off
    delay(time); //wait
  }
}
I love the pin declaration in that code. Very elegant :)
jamar30304 years ago
I love this tutorial. I just bought an Arduino and I plan on making this my first project... past "hello world". Appreciate that you posted, thanks! Did you have your son/daughter draw the Arduino and schematic in step 2? Just kidding.
chrisapalo (author)  jamar30304 years ago
Umm... I recently got paint.net and was new to it, and didn't have a good program for schematics... and I'm only 13... so...
Ha, ha! Well, being that you are 13 and can make something like this, it isn't important for you to master drawing. Mastering electronics seems more pertinent. By the way, the project worked out perfect and was easier than I thought it would be. Thanks again.
mathman474 years ago
Good job.  Interesting code.  At first I thought you coulnd't code a counter, but your's is certainly an interesting take on the code.  I would imagine changing the time could have some interesting effects with POV?
chosenone35 years ago
Hi im going to buy an arduino soon i guess (just starting with mic's) and i would like to know how much output does it give when you wrote:

digitalWrite(pinled1, HIGH);

HIGH ? how much is the voltage and amperage

and how much is LOW
can you controll them with code or you have to do it hardware way ?
chrisapalo (author)  chosenone35 years ago
Congrats!
Arduino Rocks!
Okay so
HIGH means ON and is 5V at 40milliamps, although some pins have built in resistors so check before you run the program, FYI the one that I have has a resistor on pin 13, but i'm not sure about any others.
LOW means Off... so yeah, it either gives ground or just 0V....
Hope that helps.
--Chris
What type of Arduino are you getting
it think ill buy duemilinova if i spelled it correctly
Well, if you are going to do BIG projects, I would say get aArduino Nano. If small stuff like this (Knight rider) a duemilinovewould be good, or if you want you could try out one that i had beforeits called, Seeduino, (from seeed studio depot) it has same functions,same pin layout as the duemilinove, Just the Atmel ATmega chip is SMD(surface mounted)

Good luck with with your arduino

Any questions? Feel free to ask!
so you're saying nano is better than duemilinove ?
If you need lots of work space You should get the NANO, If you do smallstuff like Blinks and led chasers. The duemillinove is good. Theduemillinove is probably most used because it can have shields such asthe Ethernet shied, Proto Shield, Xbee shield.... and more. But nano isalways good for BIG BREADBOARDING AREA!

Good luck, Select wisely.


Any questions? Feel Free to ask!
I can see that you are a begginer on the Arduino ( Not to worry, I even started like this ).

So this is the Answer to your question:

As you know, the arduino code goes like this ( the last bit )

void loop()                    
{
  digitalWrite(ledPin, HIGH);          
  delay(1000);                 
 
What (ledPin, HIGH) does not mean the voltage and power is high, it simply means that The Object you are powering is turned ON.


digitalWrite(ledPin, LOW);   
  delay(1000);                
}


Same with the (ledPin, LOW), Low just simply means that it is turned OFF.


Yea its pretty stupid, but its how it is programmed, Any question? Feel free to ask. In the meantime Have a look at this, it might help you. It will be able to tell you most of the stuff:

http://arduino.cc/en/Reference/HomePage



thanks for pointing it out :)
I will look at the reference when i will get an arduino in my hand ;]
the last question i want to ask is :
Is this c/c++ ?
if yes than can it be used with STL or any other libraries of c/c++

Yes this is C++ and no it can be used with Some C++ librarys, but not many
ElectronMad5 years ago
For the schematics, You could Use ~ExpressPCB~ (it also has schematic maker).
homunkoloss5 years ago
I would recommend that you paint your schematics with eagle (www.cadsoft.de) or fritzing (www.fritzing.org). Both are free and platform independent.
Here, I made one. I added resistors in the proper places too. The way you had them hooked up, you could only light up one or two at a time without burning out your LED's.
Schematic for 'ible.JPG
chrisapalo (author)  geeklord5 years ago
Cool thanks! Are you sure that the thing would burn out the way I hooked it up? I did not know that...
Well, they'd draw too much current and would have shortened lives. I'm pretty sure that's how I've ruined a couple of my LED's.
chrisapalo (author)  homunkoloss5 years ago
Well I decided to make this dirt cheap and ... well more DIY-ish.. so yeah but you saw the circuit.. maybe later... lets see.... See Ya!
ReCreate5 years ago
Last time i checked...The arduino software already came with an example containing this... But other than than, Neat, Though i do have one unrelated question. Why is the image in the last step so high quality? how did you bypass the low quality jpeg conversion?
chrisapalo (author)  ReCreate5 years ago
This one has a different pattern the other one goes 1 2 3 4 ... mine goes 1 12 2 23 3 34 4 ..... and so on
I didn't know the Arduino had a 23'rd and 34'th pin O_o
chrisapalo (author)  ReCreate5 years ago
Oh, they dont.. I meant that it turns on 1 1 & 2 3 3 & 4 4 and so on
Erm...it doesn't really make sense, you mean that the light would change position by fading?
chrisapalo (author)  ReCreate5 years ago
So what the transition does is it turns on the leds (just on or off pins 8 and 12 arent PWM pins) 1 then 1 and 2 2, etc. Just try out the code and compare it to the example, but either way both codes are compatible, just make sure it is meant for leds connected to pins 8- 12, and see which is best. So, I'm trying to say is well the transition is a little bit slurred, not faded but it looks smooth. Hope that helps
Oh OK thanks :D