I got bored one day as often happens, and i was trying to think of a good little project involving an arduino and some leds for some weird reason. I started thinking about knight rider now, since i do not own a 1982 pontiac trans am i decided to modify the third brake light on my 2005 ford ranger. Now i figured this would be a great job for an arduino nano. However, the nano only has six pwm outputs pulse width, modulated outputs. Now there are eight more digital, only outputs. However, two of them are used for your serial communications bus and i dont like to use those in case. I need a monitor serial port and, of course, d13 is shared with the onboard led, so that leaves us with five dedicated digital output pins. However, there are also eight analog pins, six of which can be used as digital output pins. So that gives us a total of uh carry the one. Eleven weve got a total of eleven possible digital only pins, in addition to our six pulse width modulated pins. So why do i need the pulse width? Modulation? Well, as you can see here, if we just turn leds on and off, they dont fade out. The original prop used regular incandescent or possibly halogen type bulbs. So when you turn them off, they fade out gradually giving you that nice little tracer effect. So, in order to replicate this with leds, i need to be able to fade each led out in steps, so in total i have 20 steps and, as you can see on the screen here without the pulse width modulation, the 20 steps are kind of boring actually And it doesnt really look like the knight rider effect that im going for.

However, if i fade each led out after its been turned on, you can see the difference now sped up to a little bit faster speed. It looks a lot more like the original. It looks even better once its inside of a brake light lens cover. I wanted to use 11 leds, but how do i get 11 leds to work with six pwm outputs? Well, five of those pwm outputs are going to be shared between two different leds. The way thats accomplished is switching the negative side of the led with one of the digital pins, while the positive side is shared with one of the pwm as long as only one of the two negative rails is on, only that led is going to light up. According to the pwm, now, if you want full brightness, you can light them all up, which is important for the brake light application so back to those negative pins in order to switch an led on, you apply the appropriate pwm on the positive side of the led Through a 200 ohm resistor, of course, and the negative led switches to digital low now to turn that led off, while that pwm turns the other one on you set its negative pin to input reason being as an input pin. It creates an extremely high resistance, which is effectively an open circuit. Now i did not film my original project. I took some pictures, but i didnt film it and the reason was it was a lot of trial and error.

I breadboarded an 8 led version much closer to the original, but i decided on 11 because it would really fill out the brake light a little better. So i didnt film that part, but im gon na replicate it right now using a breadboard, okay right off the bat. I made a mistake programming this uh variable voltage regulator. I got these two values reversed. The adjust pin is looking for a 1.25 volt difference from the output pin not from ground. These two resistors need to change places now. This is why you test your regulator circuit before you power your arduino. This should yield 7.625 volts dc on the output. Now lets see if we are finally successful, 7.797.8 close enough were within tolerance levels here, so we can now connect this to our arduino supply rail and, of course, it powers up and does absolutely nothing now were going to speed through taking this circuit. With these six resistors, these 11 leds and a crap ton of jumper wires and were gon na make our kit or cylon knight rider lighting effect before we do that lets disconnect the 12 volts so were going to start by adding our leds and ill. Do that really quickly here now im putting them all with the positive side this way and the negative side over here, okay, now with all 11 leds, its time that four of them are connected to the pwm outputs lets, make it the other way around so lets.

Just go ahead and flip this around it might make this a little easier. All the way around youll see why, in a moment, because im gon na do it to where the resistors are on this side. On the first, six leds were gon na put a resistor between the positive lead of the led and the next trace on the breadboard. So these five are now gon na connect directly to these five. This and this led share a pwm, you see, so i need five jumper wires. The color doesnt matter id like the lengths to be about the same though, were going to jump this ones pwm side thats the positive side of the led jump into the positive of that one next were going to create our led pairs. We accomplish this by simply jumping from one led to the next, so the positive sides, the bridge to each other next up. This is where it gets a little more tricky because, according to the arduino pin out here, weve got one two three four five six weve got six pwm, capable outputs, ive, already mapped out, which ones were using here were going to connect this resistor to number three. So that shares with this as well as this one, so the next one were gon na go to number five and yeah im gon na try and use the same. Color now were gon na go ahead and connect all the pwm outputs from the arduino to the led pairs notice that the center led is not being shared, so it has its own pwm.

You are on your very own pwm and that one is going to number 11.. The next thing we need to do is connect the negative side of each led to its respective digital out. Now the order of these is a little funny and its only because of the way i did the actual circuit board. You can do these in any order as long as the code matches again that center led that one goes directly to ground number. Six, its its own round. First led. We need analog three and i learned the hard way that analog pins, six and seven cannot be used as digital. I didnt know that at the time thats why i have zero and one in a weird order. Now ive already flashed the arduino. This is programmed to wear. First, it will pulse four times. Then itll go solid, break light for three seconds and then it will start the kit effect so lets hit the brakes, theres our brake light and Music. Okay and now it should start do i have that wrong? Okay, so its stuck in this mode for some reason lets look at the code real quick five minutes later, and here we go there we are now we have. The knight rider effect lets uh dim this light down a little bit so that you can see it in all its glory. Well, thats about it for this project. I hope you found it interesting or entertaining or useful in some way.

If so, please hit that thumbs up button. If you like videos like this hit that subscribe button down there, ive got plenty of projects coming up soon. I also do tool, reviews and unboxings, and things like that click here to check out the little song parody. I did of the intro theme tonight, writer, its only 51 seconds long so be sure to check that out and up here is something else interesting that ill decide when i upload this.