DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Bettesworth Construction
automatic night light

Automatic Night Light ON/OFF Using an LDR and BC547 Transistor

Build a low-voltage automatic night light that turns an LED on in darkness and off in bright light using an LDR and BC547 transistor.

By Bettesworth Construction Team 6 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This low-voltage circuit turns an LED on when the surrounding area becomes dark and turns it off in bright light. It uses an LDR as the light sensor, a resistor to create the switching threshold, and a BC547 NPN transistor as a low-side switch. The design is intended for a regulated 5 V DC supply and a small indicator LED—not household mains.

How the automatic night light works

An LDR, also called a photoresistor, changes resistance according to illumination. Its resistance generally falls in bright light and rises in darkness, although the exact resistance range varies by device. See the LDR data sheet information and photocell guide.

As an Amazon Associate I earn from qualifying purchases.

The LDR and a fixed resistor form a voltage-divider or bias network connected to the BC547 base:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
+5 V ─── 10 kΩ to 47 kΩ ─── base node ─── LDR ─── GND
                              |
                         BC547 base
  • In bright light, the LDR resistance becomes low and pulls the base toward ground. The BC547 switches off, so the LED goes off.
  • In darkness, the LDR resistance rises. The fixed resistor raises the base voltage, turning the BC547 on and allowing current through the LED.

This makes the circuit a practical dark detector with an LED output. It is not a precision lux meter, and it does not detect motion or occupancy.

#1 Best Overall
Creative Hobbies Plug In Night Light Module, White Plastic, Great for Making Your Own Decorative Night Lights, Pack of 10
  • 💡 READY TO CUSTOMIZE: Each module provides the perfect canvas for your decorative ideas. Add a seashell, stained glass shape, or any other design to create a unique night light.
  • 🔌 ROCKER SWITCH CONVENIENCE: Quality rocker-type on/off switch located in front ensures easy operation.
  • 📐 STANDARD SIZE: Each night light measures 1.125" wide x 2" high, designed to fit seamlessly into any standard outlet with the polarized prong on the left.
  • 💡 CANDELABRA BASE BULB: Compatible with standard candelabra base night light bulbs. Recommended 4 watts, with a maximum of 7 watts.
  • 🏡 VERSATILE & PRACTICAL: Ideal for any room in the house, these night lights offer both functionality and the opportunity for personalization.

Circuit diagram

                 +5 V
                  |
                330 Ω
                  |
                 LED
          anode --|>|-- cathode
                         |
                       Collector
                         |
                      BC547
                         |
                       Emitter
                         |
                        GND

+5 V ─── base resistor ─── Base node ─── LDR ─── GND

The LED resistor, LED, and BC547 collector-emitter path are in series. The transistor is used as a low-side switch: its emitter goes to ground, while its collector sinks the LED current.

Parts required

Component Suggested value or type Purpose
LDR Common 5 mm CdS photoresistor Detects ambient light
Transistor BC547 NPN Switches the LED
LED Standard 3 mm or 5 mm LED Night-light output
LED resistor 220 Ω or 330 Ω Limits LED current
Base resistor 10 kΩ to 47 kΩ Provides base bias in darkness
Supply Regulated 5 V DC Powers the circuit
Prototype hardware Breadboard and jumper wires Construction
Optional 50 kΩ or 100 kΩ potentiometer Adjusts the light threshold

Different LDRs can have very different bright- and dark-resistance values. For example, one photocell listing specifies an approximate range of 1 kΩ to 10 kΩ, while other LDR families differ considerably. Treat the resistor values above as starting points, not universal values.

Check the BC547 pinout first

Do not assume every BC547 has the same lead arrangement. For the package drawing in the cited onsemi BC546/BC547/BC548/BC549/BC550 data sheet, the leads are identified as pin 1 collector, pin 2 base, and pin 3 emitter. Other manufacturers, package styles, or viewing orientations may differ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Projectpak Plug in Night Light Module Includes 4 Watt Bulb, White Plastic, Great for Making Your Own DIY Decorative Night Lights, Pack of 4
  • 🌟 DIY NIGHT LIGHT KIT: This pack of 4 plug-in night light modules includes 4-watt bulbs and is perfect for creating your own custom decorative night lights.
  • 🔌 EASY TO USE: Each night light features a two-prong style with a polarized (larger) prong on the left side, an on/off switch in the front, and a 120-volt AC plug-in type.
  • 🎨 CUSTOMIZE YOUR DESIGN: Transform these simple white plastic night lights by adding your own seashell, stained glass shape, or other creative embellishments for a personalized look.
  • 💡 ENERGY-EFFICIENT: The 4-watt night light bulbs included in the pack provide sufficient brightness without consuming excessive power, making these night lights an energy-saving choice.
  • 🛠 VERSATILE APPLICATIONS: These night lights are perfect for DIY projects, crafters, decorators, or those looking for a personalized gift idea.

Read the data sheet for the exact transistor in your hand before inserting it into the breadboard. A reversed collector and emitter can leave the LED permanently off, dim, or apparently stuck on.

Step-by-step wiring

  1. Connect the regulated supply negative to the breadboard ground rail and the positive output to the +5 V rail.
  2. Connect the BC547 emitter to ground.
  3. Connect the BC547 collector to the LED cathode, usually the shorter lead. Confirm the LED marking if uncertain.
  4. Connect the LED anode to one end of a 330 Ω resistor.
  5. Connect the other end of the 330 Ω resistor to +5 V.
  6. Connect one end of a 10 kΩ or 22 kΩ base resistor to +5 V.
  7. Connect the other end of that resistor to the BC547 base. This junction is the base node.
  8. Connect either LDR terminal to the base node and the other LDR terminal to ground. An LDR is not polarized.
  9. Inspect the breadboard for misplaced jumpers and unintended connections before applying power.

Testing the circuit

  1. Power the circuit with the LDR uncovered. Under normal bright room lighting, the LED should be off.
  2. Shine a flashlight on the LDR. The LED should remain off.
  3. Cover the LDR completely. Its resistance should rise and the LED should turn on.
  4. If the response is weak or occurs at an unsuitable light level, measure the base voltage and adjust the base resistor or add a potentiometer.

Choosing the LED resistor

Use this approximate equation:

RLED = (Vsupply − VLED − VCE(sat)) / ILED

For a typical red LED at 5 V, using approximately 2.0 V forward voltage, 0.25 V transistor saturation voltage, and 10 mA LED current:

RLED ≈ (5 − 2.0 − 0.25) / 0.01
RLED ≈ 275 Ω

The next common value, 330 Ω, is a conservative choice and produces roughly 8 mA under typical conditions.

Rank #3
CHEZBABY 12-Pack Plug-in Night Light Rotatable Base
  • Package Contents: Includes 12 sets of night light bases, each equipped with a 0.8W LED bulb (equivalent to a 7W incandescent bulb) and brass mounting clips, meeting your daily replacement maintenance and multi-scenario usage needs.
  • Easy Installation: Complete setup in three simple steps—screw the LED bulb into the base, attach the lampshade to the mounting clip, and then clip it onto the socket base.No tools required, ready to use instantly.
  • Sturdy & Reliable:The base is made of plastic, sturdy yet lightweight.The rotating base is compatible with 110–120V AC power, supporting up to a 3W LED or 10W incandescent bulb, widely suitable for various home decorative lighting.
  • Space-Saving Design:The rotating base measures only 30×50 mm (approx 1.18×1.97 inches), compact enough not to block other outlets,allowing flexible placement that blends seamlessly into any space.
  • Wide Compatibility: Ideal for bedside lamps,small night lights, decorative lighting,LED wall lights,sensor night lights, and more.The simple white design effortlessly complements different home styles, adding warmth to any corner.

For a typical white LED with approximately 3.0 V forward voltage, the calculation gives about 175 Ω at 10 mA; 220 Ω is a sensible starting value. Actual forward voltage varies by LED color and manufacturer. The onsemi data sheet gives BC547-family saturation test values of approximately 90–250 mV under specified conditions, not a guaranteed value for every circuit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Never connect an LED directly across the supply. It requires a current-limiting resistor. If using several LEDs, give each independently driven LED its own resistor rather than relying on one shared resistor.

Choosing the base resistor

With a 10 kΩ base resistor, a rough maximum base-current estimate is:

Rank #4
Creative Hobbies White Plug in LED Night Light with Switch, Manual On Off Nightlight for Bathroom, Hallway, Garage, Bedroom, Nursery, UL Listed | 4 Pack
  • Creative Hobbies Wholesale Pack of 4 White Night Light Sockets with Quality Rocker-type On/off Switch in Front, LED night light bulbs and 4 Matching Clips
  • Each Night Light is 1.125" Wide and 2" High overall and is a two prong style with the polarized (larger) prong on the left side.
  • Great for using as they are or adding your own seashell or stained glass shape to the front for a custom look.
  • LED Single Edison Filament Night Light Bulbs are C7, E12 US Standard Candelabra screw base,120V / 0.6W (7 Watt equivalent incandescent) bulbs / 25,000 hours lifespan / 60 Lumen / 2700K soft white, Non-Dimmable.
  • 120 volt AC plug in type, 7 watt max bulb.
IB ≈ (5 V − 0.7 V) / 10 kΩ
IB ≈ 0.43 mA

A 22 kΩ or 47 kΩ resistor may work for a low-current indicator, but the circuit becomes more dependent on the LDR’s characteristics and transistor leakage. Start with 10 kΩ for a small LED, then tune it if necessary.

Do not design around one assumed “BC547 gain.” The cited onsemi data sheet lists different gain classifications, approximately 110–220, 200–450, and 420–800 under specified test conditions. The 100 mA collector-current figure is an absolute maximum, not a recommended target.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Adjusting the switching threshold

For easier calibration, replace the fixed base resistor with a 50 kΩ or 100 kΩ potentiometer:

Best Value
Deridi Plug in Night Light Module Socket with ON/Off Switch with Shade Mounting Clip for Decoration for Your Night Light (10Pack)
  • High Quality: Made of high-quality plastic materials, sturdy and easy to use
  • Specifications: For 110-120V AC power supply and can connect up to 10W bulbs
  • High quality design: The size of the Lights Base 2.18 x 2.01 inches which does not occupy space in other sockets and is convenient to use
  • Easy to install: The night light base is easy to install incandescent bulbs or LED night lights, simply plug into the wall socket
  • Widely Used: These white night light bases are suitable for any room and home style, suitable for bedside lamps, small night lights, etc.
+5 V ─── potentiometer ─── base node ─── LDR ─── GND
  1. Install the sensor in its intended enclosure or location.
  2. Set the room to the brightness at which you want the LED to turn off.
  3. Adjust the potentiometer until the LED is just off.
  4. Cover the LDR and confirm that the LED turns on.
  5. Check the result at different times of day because window light and reflections can change the threshold.

A potentiometer provides adjustment, not a precise lux setting. The LDR’s response depends on its device characteristics, light spectrum, temperature, position, and previous exposure to light.

Troubleshooting

Symptom Likely causes Checks and fixes
LED always on Wrong resistor arrangement; incorrect transistor pinout; insufficient light; base shorted high; open LDR Confirm the LDR is between base and ground, measure LDR resistance, check base voltage, and verify the BC547 data sheet.
LED always off Reversed LED; emitter not grounded; incorrect pinout; LDR shorted; base resistor too large; unpowered rail Test the LED separately with a resistor, cover the LDR, and measure for about 0.6–0.8 V from base to emitter when the transistor should conduct.
LED flickers Ambient light is near the switching point; LED light reaches the sensor Shield or reposition the LDR, add a small capacitor for slower response, or use a comparator with hysteresis.
LED is dim LED resistor too large; inadequate base drive; low supply; high-forward-voltage LED; wiring error Check supply voltage and transistor wiring, then reduce resistance only after verifying LED and transistor current.
Threshold changes after installation Enclosure, reflections, window light, temperature, or LED feedback Calibrate with the sensor installed and physically separate the LDR from the LED.
Battery drains quickly Bias current flows continuously through the sensor network Use larger resistor values where reliable switching permits, reduce LED current, or use a low-power comparator or MOSFET design.

Limitations and upgrades

The bare transistor circuit has no hysteresis, so flicker near its threshold is expected. A comparator such as an LM393 with hysteresis gives cleaner, separate turn-on and turn-off levels. A small capacitor can reduce rapid changes but also slows the response.

For an LED strip, relay, motor, fan, or other larger load, use a properly rated driver—often a logic-level MOSFET—with a suitable power supply and protection components. A BC547 is intended here for a small indicator LED. Its cited absolute maximum ratings include 100 mA collector current, 45 V collector-emitter voltage for BC547, 500 mW power dissipation, and 6 V emitter-base voltage; these limits should not be treated as normal operating targets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

LDRs are inexpensive and useful for learning, but their resistance is not a calibrated measure of illumination. CdS photocells may also be unsuitable where RoHS compliance is required. A phototransistor, calibrated sensor, or comparator module may be preferable for a regulated product.

Safety

  • Use only a low-voltage DC source such as regulated 5 V.
  • Never connect this breadboard circuit directly to 120 V or 230 V AC mains.
  • Do not use the BC547 as a direct household lamp, heater, motor, relay, or large LED-strip controller.
  • For mains lighting, use a certified enclosed product or a properly rated, isolated switching design outside this beginner circuit.

The result is a simple, useful ambient-light switch: when the LDR is dark, the base rises and the BC547 completes the LED’s ground path; when light lowers the LDR resistance, the base is pulled down and the LED switches off.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Site Office

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.