Automatic Street Light Circuit Using LDR and BC547 Transistor
Build an automatic street light that turns on in the dark with an LDR and a BC547 transistor. Wiring table, calculations, tuning and fixes.
On this page
A street light that switches itself on at dusk and off at dawn feels like magic, but the idea is simple. A light-dependent resistor (LDR) changes its resistance with the brightness around it, and one BC547 transistor turns that change into an on or off signal for some LEDs. No microcontroller, no code, and only a handful of cheap parts.
This is a good project for science exhibitions in school and for your first lesson in how a transistor and a voltage divider work together.
Safety note
Keep this circuit on a low-voltage supply (9 V battery or a 5 V to 12 V DC adapter). Do not connect it to mains wiring. If you later want to switch a real lamp, use a ready-made, properly insulated relay module and have any mains wiring done by a qualified electrician.
What you need
Scroll sideways to see all columns.
| Item | Qty | Notes |
|---|---|---|
| LDR (photoresistor), GL5528 type | 1 | 5 mm disc with a wavy track; no polarity |
| NPN transistor BC547 (or BC548) | 1 | TO-92 black plastic package |
| Resistor 10 kΩ (R1) | 1 | Protects the base when the preset is at zero |
| Preset (trimmer) 220 kΩ, or 100 kΩ (VR1) | 1 | Sets the darkness level. Any value of 100 kΩ to 500 kΩ is fine |
| White LEDs 5 mm | 3 | Street light "lamps" |
| Resistor 470 Ω (R2, R3, R4) | 3 | One per LED |
| 9 V battery with clip, or 9 V DC adapter | 1 | 5 V to 12 V also works |
| Breadboard and jumper wires | 1 set | |
| Digital multimeter | 1 |
Connection table
Hold the BC547 with the flat side facing you and the legs pointing down. From left to right the legs are Collector, Base, Emitter (C-B-E). Some other transistors (such as the 2N3904) use a different order, so always check the datasheet for the part number you hold.
Scroll sideways to see all columns.
| Pin or terminal | Connects to |
|---|---|
| Battery + | R1 (one end) and the anode side of each LED resistor |
| R1 other end | One outer leg of VR1 |
| VR1 centre leg | BC547 base, and one leg of the LDR |
| VR1 other outer leg | Leave unconnected (or join to the centre leg) |
| LDR other leg | Battery − |
| BC547 emitter | Battery − |
| BC547 collector | Cathodes (short legs) of all three LEDs |
| LED anodes (long legs) | One 470 Ω resistor each, other end to battery + |
Signal path in one line:
+V → R1 → VR1 → (base node) → LDR → GND ; +V → 470 Ω → LED → collector → emitter → GND
How it works
An LDR has high resistance in the dark and low resistance in light. A GL5528 type is typically around 10-20 kΩ at about 10 lux (dim room), falls to a few kΩ or less in bright daylight, and can reach around 1 MΩ or more in darkness. Exact values differ between parts, which is why the circuit has a preset to tune it.
R1 + VR1 (call their total R_top) and the LDR form a voltage divider feeding the base of the transistor.
- Daytime: the LDR resistance is low, so it pulls the base voltage down near 0 V. The base is below about 0.65 V, the transistor stays off, and the LEDs are off.
- Night: the LDR resistance is high, so the divider pushes the base up. Once the base reaches about 0.65 V to 0.7 V, base current flows, the transistor turns on and the LEDs light.
Choosing the threshold (the math)
The transistor starts to switch when the base voltage reaches about 0.65 V. With a 9 V supply and ignoring base current before the transistor starts to conduct:
V_base = 9 × R_LDR / (R_top + R_LDR) = 0.65
Solving: R_LDR = 0.078 × R_top
So the transistor starts conducting when the LDR resistance rises above about 7.8% of R_top.
Scroll sideways to see all columns.
| R_top (R1 + VR1) | LDR resistance at the approximate start of conduction |
|---|---|
| 10 kΩ (preset at 0) | about 0.8 kΩ (lights on even in a bright room) |
| 60 kΩ | about 4.7 kΩ |
| 110 kΩ | about 8.6 kΩ |
| 230 kΩ (preset at max) | about 18 kΩ (lights on at early dusk) |
Increasing the preset resistance makes the LEDs come on in deeper darkness. Decreasing it makes them come on earlier. The 10 kΩ resistor R1 stops the preset from ever being zero ohms, which would otherwise push too much current into the base.
LED current
Each white LED drops about 3.0 V to 3.2 V. The transistor drops about 0.1 V to 0.2 V when fully on.
I = (9 − 3.1 − 0.15) / 470 ≈ 12 mA per LED, so about 37 mA for three if the transistor is saturated. The divider supplies less than 0.84 mA of base current even at the minimum preset resistance. Brightness therefore depends on the preset and transistor gain, and the LEDs may be dim at high preset settings.
Step-by-step build
- Insert the BC547 on the breadboard with the flat side facing you. Note which leg is the collector (left), base (centre) and emitter (right).
- Connect the emitter to the − rail.
- Build the divider: R1 from the + rail to an outer leg of the preset. Join the preset centre leg to the base. Put the LDR between the base and the − rail.
- Connect the three LEDs: each anode through a 470 Ω resistor to the + rail, and all three cathodes to the collector.
- Connect the battery and cover the LDR with your finger. The LEDs should light. Uncover it under a lamp or in daylight, and they should go off.
- Adjust the preset to set exactly how dark it must be before the lights come on.
Tip: keep the LDR pointing away from the LEDs. If the LEDs shine onto the LDR, it "sees" light, switches the LEDs off, sees darkness again and flickers. Put the LDR facing the sky and the LEDs facing down.
Testing with a multimeter
- Supply: battery voltage across the + and − rails, about 9 V.
- Base voltage (red on base, black on −): in bright light, you should read below 0.3 V. Cover the LDR slowly and watch the reading climb to about 0.65-0.7 V, then stop, as that is the transistor's base-emitter drop.
- Collector voltage when on: measure from collector to the − rail. It should be around 0.1 V to 0.3 V. If it reads 5 V or more with the LEDs lit, the transistor is not turned on fully.
- LDR resistance: remove the LDR and use the Ω range. You should see a few kΩ in bright light and hundreds of kΩ when you cover it.
- Transistor check: many meters have an hFE socket. A good BC547 typically reads from about 110 to 800 depending on the letter (A, B, C).
Troubleshooting
Scroll sideways to see all columns.
| Symptom | Likely cause | Fix |
|---|---|---|
| LEDs always on | Preset too high, or LDR not connected | Turn the preset down; check the LDR leads |
| LEDs never light | Transistor reversed (C and E swapped), or LEDs backwards | Check flat side and C-B-E order; flip LEDs |
| Lights flicker at dusk | LED light falling on the LDR | Shield the LDR from the LEDs |
| Switches too late (needs full dark) | Preset too low | Turn the preset up (higher R_top) |
| LEDs dim | Battery weak or 470 Ω resistors too large | Check voltage, try 330 Ω |
| Transistor gets hot | Load above 100 mA | Fewer LEDs or use a bigger transistor |
| Works on breadboard, fails when soldered | Dry joint or damaged LDR leads | Reflow the joints |
FAQ
Can I run it from a 12 V adapter?
Yes. Increase each LED resistor to about 680 Ω ((12 − 3.1 − 0.15) / 0.012 ≈ 730 Ω, so 680 Ω is close). The threshold math changes: R_LDR = 0.057 × R_top at 12 V, so re-tune the preset.
Can I switch a larger lamp?
Use the LDR divider with a comparator and a relay driver rated for the coil current. The simple divider here supplies too little base current for most relay coils. See our transistor switch tutorial for the driver and flyback diode, and use a low-voltage lamp.
Why not use the LDR in the opposite position?
Swapping the LDR and the preset gives the opposite behaviour: LEDs on in the day and off at night. Handy to remember if your light behaves backwards.
My LDR has slightly different values.
That is normal. Adjust the preset by looking at your own LDR values with the multimeter.