A light sensor and a divider
The light sensor is a resistor whose value falls as light reaches it. A meter reads voltage, not resistance in a live circuit, so a second resistor turns the change into a voltage. Then a transistor turns that voltage into a lamp that comes on when it gets dark.
You need the transistor circuit working, one light sensor, a 10 kΩ and a 4.7 kΩ resistor, a 220 Ω resistor, a red LED and the meter. The numbers here come from a typical small light sensor, not from yours: the listing does not name the part, so measure yours and use that.
A resistor that listens to light
The light sensor is almost certainly a photoresistor, the brown disc with a wavy track on its face. The track is a light-sensitive material, and light that reaches it frees charge carriers, so current finds an easier way through. In the dark the resistance is huge, a megohm or more. In bright light it falls to a few hundred ohms.
The direction is not in doubt. The size is: a part from another batch can be a few times higher or lower. That is why the first thing to do is measure.
Measure the sensor
Take the sensor out of any circuit, so nothing else is in parallel with it, and power off. Set the meter to resistance and put one probe on each leg. The legs have no polarity, so either way round is right.
- Cover it with your hand, shutting out the light: write the reading down.
- Room light, uncovered: write it down.
- Phone torch a few centimetres from the disc: write it down.
Expect the dark reading to be hundreds of times the torch one. A reading that stays near one value whatever you do means the part is not what this article assumes: go back to a part with no label.
From a resistance to a voltage
A meter on a live circuit reads voltage most easily, and an LED does not care about resistance at all, only about the voltage on its base. So put the sensor in a voltage divider: a fixed resistor from the plus rail to a middle point, the node, and the sensor from the node to ground. The node sits at the sensor's share of the rail.
In the dark the sensor is large, takes most of the rail, and the node is high. In the light the sensor is small and the node falls toward zero.
The fixed resistor decides where on the light scale the node moves most. The output is half the rail when the sensor equals the fixed resistor, so choose a fixed resistor near the geometric mean of your dark and torch readings: multiply them, take the square root. The kit's values are 100 Ω, 220 Ω, 1 kΩ, 4.7 kΩ, 10 kΩ and 1 MΩ; take the nearest. For the sensor modelled here, 10 kΩ is nearest.
Build the divider
Seat the sensor and the resistor like this, with the power module on its 5 V side. The rail is about 4.8 V, so everything below is calculated with that.
- A jumper from the plus rail to column 1, row a.
- The 10 kΩ from column 1, row c to column 5, row c.
- The sensor's legs in column 5, row d and column 7, row d.
- A jumper from column 7, row b to the minus rail.
Measure the divider
Meter on DC volts, black lead on the minus rail, red lead on column 5, which is the node. First measure the rail with the same probes on the rail pins, because the node is a share of whatever the rail really is.
- Covered: close to the rail, 4.5 to 4.9 V.
- Room light: between the two. On the modelled sensor it sits near 0.5 V in a bright room and near 2 V in a dim one.
- Torch: close to zero, a few tenths of a volt at most.
Write the three down against your three resistances. Check one with Ohm's law: the node should equal the rail times the sensor over the sum of the two resistors, within the meter's error.
A lamp that comes on in the dark
The node is high in the dark and low in the light, which is the right way round for a lamp. Feed it to the base of the S8050 from the transistor article through a 4.7 kΩ resistor. No pull-down is needed here: the sensor itself, small in the light, holds the base low.
Keep the divider where it is and add, in the lower half:
- A jumper from column 5, row e across the centre channel to column 5, row f.
- The 4.7 kΩ from column 5, row j to column 10, row j.
- The S8050, flat face towards you, in column 9, row h (emitter), column 10 (base) and column 11 (collector). Check the order with the meter's diode mode, as the last article showed.
- A jumper from column 9, row i to the lower minus rail.
- The LED: the long leg in column 12, row f and the short leg in column 11, row f.
- The 220 Ω from column 12, row g to column 16, row g, and a jumper from column 16, row h to the lower plus rail.
A soft switch
Cover the sensor and the LED lights. Uncover it and it goes out. But slide the light level slowly through the middle and the LED does not snap: it dims.
A transistor amplifies a current. It does not compare two voltages. The base current rises smoothly as the node passes about 0.65 V, and the collector current follows, so the LED fades over about half a decade of light. That is good enough for a night light and wrong for anything that must switch cleanly. A chip made to compare two voltages would.
Measure the lamp
With the lamp built, check each state.
- Covered: the LED is on. The node reads close to the rail. Across the 220 Ω you should read about 2.8 V, which is 12 mA by Ohm's law. Across the transistor's base and emitter, the meter reads about 0.65 V.
- Room light: the LED is off or very dim. The node is under 0.65 V, so no base current flows.
- In between: shade the sensor slowly. The LED fades, and the node passes through the base's 0.65 V on the way.
Then change the fixed resistor to the next kit value up and down and find the brightness at which the lamp switches. The bigger one switches in a darker room, the smaller in a brighter one.
When it does not work
Measure the node with the meter while the sensor is covered. It should be close to the rail. If it is, the divider works and the fault is in the transistor half: check the jumper that carries the node across the centre channel, the 4.7 kΩ on the base, the flat face of the transistor and which way round the LED is. If the node is low, the sensor is shorted: both its legs are in one strip.
A sensor that is not making contact leaves the node connected only to the rail through the 10 kΩ, so the node reads the rail and the transistor is on. Press the legs in, or move them to fresh holes. The same happens if the jumper from the sensor's far leg to the minus rail has come out. Measure the node: in a lit room it should be under half a volt.
Photoresistors of this kind are slow. They follow light in a fraction of a second but can take seconds to settle after bright light, so the reading creeps. Wait for it to stop before writing a number down. Mains-powered lamps also flicker a little, which the sensor averages out.
Change the fixed resistor. A bigger one moves the switch point to a darker room, a smaller one to a brighter room: the output is half the rail when the sensor equals the fixed resistor. Take the sensor's resistance in the light level where you want the lamp to switch, and use the kit resistor nearest to it.
The temperature sensor is the same idea with a different cause: a resistor that changes with heat instead of light.
A thermistor and a divider →Edit this page — content/books/estkit/a-light-sensor-and-a-divider.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Electronics Starter Kit, Breadboard, Power Module and Components
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.