Welcome to designing your own light sensing nightlight! This Instructable is based on my favorite undergraduate electrical engineering lab. In fact, I've shared it with family members because it is well within the abilities of someone with basic knowledge of circuit design and it has a really cool result.
If you embark on this journey with me, you will reach the end with a working nightlight and a grasp of the fundamentals of electrical engineering. First we will discuss some necessary concepts, then gather the materials needed for our grand adventure. We will stride through the nightlight's design and arrive at the building stage in triumph. In the end, you stand in the victory glow of your light sensing nightlight.
Step 1: Concept - Wheatstone Bridge
A Wheatstone bridge is most often used to compare the two voltages on either side of the "bridge" where one voltage is held in place by two resistors with fixed values, and the other can vary because there is a variable resistor on that side of the Wheatstone bridge. The variable resistor is used to measure some kind of outside stimulus; in our case, this is light.
- Two normal resistors in series makes one fixed leg
- One normal resistor and one photocell (light sensing) resistor makes the variable leg
- The photocell has a large resistance in the dark and a small resistance in the bright light
- When the photocell has a large resistance, Vb is greater than Va
- When the photocell has a small resistance, Vb is smaller than Va
- When the op-amp conducts, it will turn the LED on
- If Vb is greater than Va, the op-amp will conduct.
Step 2: Concept - Bias Resistor
- LEDs require 2 Volts to turn on, but they can't control the current flowing through them
- Too much current will burn them out and destroy the LED
- We will use a Bias Resistor to limit the current and protect the LED
- If you decide to use multiple LEDs in your nightlight, each LED MUST have its own bias resistor
Step 3: Concept - Circuit Board
Before you can build your very own night-light, you need to understand how the circuit board is laid out. If you are using your own trusty circuit board, feel free to move on to the next step. If you are using the A & D (nicknamed ANDY) board in the materials list, pay attention to this section.
CAUTION: IMPROPER WIRING OF CIRCUIT MAY RESULT IN DAMAGE TO THE COMPONENTS
The ANDY board is arranged in two symmetrical halves, one on top and one on the bottom. We will only need one half for this experiment. There are two long rows along the top of the circuit: these are your power rails. You will connect the rail near the red line to the black square marked '9V' using red wire. Then, use black wire to connect the black square marked 'Ground' to the rail near the blue line to create your ground rail.
Now, the short columns of five holes are shorted together, so you can use them to form a connection between two circuit components like a wire. There is no connection between the holes that are next to each other horizontally, nor between the columns of five holes separated by the valley in the circuit board.
Step 4: Materials
- Cadmium Sulfide photocell resistor (pictured above)
- Circuit breadboard (I am using the RSR/VT A&D "ANDY" Board)
- Wire stripper
- Standard resistor kit Red LED (at least 1, but can use multiple for brighter light)
- LM324N op-amp/comparator
- Multimeter test probes
Step 5: Design - Photocell Range
- Use the multimeter to measure the photocell's resistance in complete darkness by covering the light sensor with your thumb
- I measured 30 k-ohms
- Measure the photocell's resistance in a bright room
- I measured 1.89 k-ohm
Step 6: Design - Calculate the Individual Values of the Resistors
- Current Limiting Resistors R1 & R3
- R3 must be big enough to limit the current through the variable leg to less than 0.5 mA even when the photocell is at its smallest resistance. V = I/R, so the minimum total resistance in each leg of the Wheatstone bridge must be at least 9V/0.5mA = 18k-Ohm.
- Select R3 = 18k-ohm
- For design simplicity, set R1 = R3.Therefore R1 = 18k-ohm
- Threshold Resistor
- The threshold resistor is R2 in the schematic, which needs to be approximately 80% of the value of the photocell in total darkness. This means that the nightlight will turn on when it is slightly brighter than total darkness.
- For my resistor values, I need a resistor approximately 80%*30k-ohm = 24k-ohm.
- Choose the closest standard value
- R2 = 22k-ohm
Step 7: DesignDesign - Calculate LED's Bias Resistor
- First, find the voltage that you need the LED’s bias resistor to dissipate.
- When it is connected to a 9V supply, the LM324N op/amp outputs approximately 7.5V. The LED has a fairly small internal resistance, so a relatively large voltage divided by a small internal resistance means that if we do not protect the LED, a huge amount of current will flow through it and burn it out. The red LED’s can only support approximately 10mA of current, so we need to add a bias resistor to limit the current through the LED to 10mA
- Subtract the LED's voltage from the op-amp's output voltage
- 7.5V - 2V = 5.5V
- Divide the voltage across the bias resistor by the maximum amount of current that can flow through the LED
- 5.5V / 10mA = 550 ohms
- If you do not have a resistor precisely this size, err on the larger side.
- I am using a 560 ohm resistor
Step 8: WARNING
WARNING: TO AVOID ELECTRIC SHOCK, DO NOT TOUCH PINS ON BOTTOM OF CIRCUIT BOARD
The circuit must be on a hard flat surface before you plug it in. Many circuit boards have electrical pins on the bottom. If the circuit board is not placed on a hard, flat surface, it’s possible that an electrical short circuit could form between the pins, burning the carpet. If you are holding the circuit on your lap, it could shock you.
Step 9: Building Your Nightlight - Op-Amp Inputs
- Insert the op-amp into the circuit board.
- The op-amp MUST be placed over the valley in the circuit board
- This ensures that its pins are not shorted together
- The op-amp MUST be placed over the valley in the circuit board
- Wire the op-amp
- Connect the 9V supply rail in the V+ input of the op-amp and the ground rail to the ground input of the op-amp
- Connect the FIXED leg of the Wheatstone bridge to the NEGATIVE input of the op-amp.
- Connect the VARIABLE leg of the Wheatstone bridge to the POSITIVE input of the op-amp.
- Place the bias resistor on the output of the op-amp
- NOTE: the op-amp has four sets of inputs and outputs. It does not matter which set you choose, but you MUST use the inputs and output from the same set.
- Schematic image courtesy of Dr. Arthur Ball's 2074 Electric Circuit Analysis Lab Presentation Slides
Step 10: Building Your Nightlight - Inserting the LED
- LED Polarity
- LED's have a positive end (cathode) and negative end (anode)
- There are two ways to tell which end of the LED is the cathode
- The cathode is attached to the longer stick of wire
- The anode side has a flat ledge on it
- When inserting the LED be sure that the cathode is connected to the bias resistor
- The anode should be grounded
- The op-amp can output as much current as necessary to maintain it's 7.5V output, so adding more LEDs is not a problem
- Each LED MUST have it's own bias resistor
- Add as many LEDs as needed to achieve the desired amount of light
Step 11: Conclusion
We have arrived at the end of our journey together, and you should have a fully functional nightlight. If, for some reason, your nightlight is not working, double check your connections and the orientation of your LED. I hope that you enjoyed our venture into the world of circuit design, and I wish you all the best in continuing your voyage.