Intro: Blinking Nightlight (by Request)
Instructables user Pagemaker provided a link to a generic blinking circuit using a 555 timer, and requested info on how to incorporate a photoresistor to enable the circuit to turn off in daylight. In addition, Pagemaker wanted to use more that one LED. His original posting is HERE. This instructable will show you how to do just that.
Step 1: Looking at the Initial 555 Circuit
The first step in creating the blinking nightlight was to analyze the original circuit, which can be found here.
There are a number of websites that will teach you everything you need to know about 555 timers, so I'll leave that to others. Here are a two of my personal favorite sites on 555 timers that will get you started:
Basically, depending on what external components (resistors and capacitors) we use, we can change the rate of blinking.
Step 2: Calculating the Desired Resistor Value for Our LEDs
LEDs are current-driven. They require a current in order to operate. The average red LED has a normal operating current of about 20 mA, so that's a good place to start. Because they are current-driven, the brightness of the LED depends on the amount of current flow, and not the voltage drop across the LED (which is about 1.5-1.7 volts for your average red LED. Others vary).
This sounds great, right? Let's just pump a ton of current through, and we'll have super-bright LEDs!
Well... in reality, an LED is only able to handle a certain amount of current. Add much more than that rated amount, and the magic smoke starts leaking out :(
So what we do is add a current-limiting resistor in series with the LED, which fixes the problem.
For our circuit, we'll have 4 LEDs in parallel. We have two options for our series resistor(s):
Option 1 - Place a resistor in series with each LED
With this option, we treat each LED separately. To determine the series resistor value, we can simply use the formula:
(V_s - V_d) / I = R
V_s = Source voltage (In this case we're using two AA batteries in series, which is 3 volts)
V_d = The voltage drop across our LED (We're figuring about 1.7 volts)
I = The current we want running through our LED in Amps
R = Resistance (the value we want to find)
So, we get:
(3 - 1.7) / 0.02 = 65Ω
65 ohms is not a very standard value, so we'll use the next size up, which is 68 ohms.
PROS: Each resistor has less power to dissipate
CONS: We have to use a resistor for EACH LED
I checked this value in the following way:
I measured each LED for resistance, and determined each was about 85 ohms. Adding that to the resitor value gets us about 150 ohms on each of the 4 parallel nodes. The total parallel resistance is 37.5 ohms (remember that resistance in parallel is lower than resistance of any single node).
Because I = E/R we can determine that 3V / 37.5Ω = 80mA
Divide that value by our 4 nodes, and we see that we're getting about 20 mA through each, which is what we want.
Option 2 - Place a resistor in series with the entire group of 4 parallel LEDs
With this option, we'll treat all of the LEDs together. To determine the series resistor value, we have to do a bit more work.
This time, using the same value of 85Ω per LED, we take the total parallel resistance of our LEDs (without and additional resistors), and we get 22.75Ω.
At this point, we know the current we want (2mA), the source voltage (3V), and the resistance of our LEDs in paralles (22.75Ω). We want to know how much more resistance is needed to get the value of current we need. To do this, we use a bit of algebra:
V_s / (R_l + R_r) = I
V_s = Source voltage (3 Volts)
R_l = LED resistance (22.75Ω)
R_r = Series resitor value, which is unknown
I = Desired current (0.02A or 20mA)
So, plugging in our values, we get:
3 / (22.75 + R_r) = 0.02
Or, using algebra:
(3 / 0.02) - 22.75 = R_r = 127.25Ω
So, we can put a single resistor of about 127Ω in series with our LEDs, and we'll be set.
PROS: We only need one resistor
CONS: That one resisor is dissipating more power than the previous option
For this project, I went with option 2, simply because I wanted to keep things simple, and 4 resistors wehre one will work seems silly.
Step 3: Blinking Several LEDs
At this point, we've got our series resisitance, we can now blink several LEDs at once using our original timer circuit, simply by replacing the single LED and series resistor with our new series resistor and set of 4 parallel LEDs.
Below, you'll see a schematic of what we've got so far. It looks a little different than the circuit on the original link, but it's mostly just appearances. The only real difference between the circuit at http://www.satcure-focus.com/tutor/page11.htm and the one in this step are the resistance value for the current-limiting resistor, and the fact that we now have 4 LEDs in parallel, rather than just a single LED.
I didn't have a resistor of 127 ohms, so I used what I had. Normally we'd prefer to approximate upwards, selecting the next largest resistor value in order to ensure we don't let too much current through, but my next closest resistor was MUCH larger, so I chose a resistor slightly below our calculated value :(
We're making progress, but we still only have a bunch of blinking lights. On the next step, we'll make it turn off in daylight!
Step 4: Making It a Nightlight
Enough with simple blinking! We want it to work at night, and stay off during the day!
Alright, let's do it.
We need a few more components for this step:
- A photoresistor (sometimes also called an optoresistor)
- An NPN transistor (most any will do. I can't even read the label on the one I picked, but I was able to determine it's NPN)
- A resistor
A photoresistor is simply a resistor that changes it's value depending on how much light is applied. In a bighter setting, the resistance will be lower, while in the dark, the resistance will be higher. For the photoresistor I have on hand, the daylight resistance is about 500ÃÂ©, while the resistance in darkness is nearly 60kÃÂ©, quite a large difference!
A transistor is a current-driven device, whcih meand that in order for it to operate correctly, a certain amount of current must be applied. For this project, nearly any general purpose NPN transistor will do. Some will work better than others, depending on the amount of current required to drive the transistor, but if you find an NPN, you should be good to go.
In transistors, there are three pins: the Base, emitter and collector. With an NPN transistor, the base pin must be made more positice than the emitter in order for the transistor to work.
The general idea here is that we want to use the resistance of the photoresistor to adjust how much current is allowed to flow through the LEDs. Because we don't know the exact current required for our Transistor, and because you may be using a different photoresistor than me, the value of your resistor in this step (R4 in the picture below), may be different than mine. This is where experimentation comes in. 16k was just about perfect for me, but your circuit may require a different value.
If you look at the schematic, you'll see that as the resistance value of the photoresistor changes, so too does the current through the base pin.
In dark conditions, the value of resistance is very high, so most of the current coming from V+ on the 555 Timer (V+ is the positive voltage) goes both directly to the base of the transistor, making it operational, and to the LEDs.
In lighter conditions, the lowered value of resistance in the photoresistor allows much of that current to go from V+ on the timer directly to DIS. Because of this, there's not enough current to drive the transistor and the LEDs, so you don't see any blinking lights.
Next we'll see the circuit in action!
Step 5: Lights (or Not), Camera, Action!
You will notice in the video that there is a duty cycle of about 90% (the lights are on 90% of the time, and blink off for 10% of the time). This is due to the external components (resistors and capacitors) attached to the 555 timer. If you're interested in changing the duty cycle, please review th links I provided earlier. If there's interest, I'll write up an instructable on it.
Hope this instructable was helpful. Feel free to make any corrections or ask any questions. I'd be glad to assist where I can.