Introduction: LED Nightlight That Turns on in the Dark

Picture of LED Nightlight That Turns on in the Dark

My first instructable! This is something I originally made for a friend who's still using it. It works very nicely at adding a nice ambient light to a dark room. I made this instructable because I decided to make one to stick in the bathroom at my house.

It's a small easy to build circuit that will, as the title says, turn an LED on when it's dark and turn it off when there's light, making it a perfect night light. It runs on a 12v wall adapter, so you won't need to worry about replacing a battery.

Step 1: What You Need

Picture of What You Need

So here's what you need for this project:

[Soldering iron, of course... and solder]

- 100k Resistor
- 1K Resistor
- NPN Switching transistor (2N4401)
- Photo Cell
- 3v LED
- 12v wall adapter (look around... I'm sure you've got one somewhere!)


- Small circuit board (makes it easier!)
- SPDT Switch (for complete disconnection)

Step 2: The Schematics

Picture of The Schematics

As said previously, the circuit is very simple.

The transistor switches what happens with the LED. Without it the LED would turn on when the lights are on and that'd be useless. The 100k resistor limits how much light is needed to turn it off, and the 1K resistor limits the amount of voltage going to the LED.

You can experiment with different resistor values. In this project I used two 100K resistors because I wanted the night light to be more sensitive and stay off in most ambient light. You could very easily replace these with a variable resistor, like a small trim pot, to let you determine the sensitivity whenever you'd like. You could also change the 1K resistor, but a lower value may make the maximum brightness a little too bright for a night light.

I also used 3 white LEDs for this project instead of one (which didn't work out as well as I'd hoped, stick to one).

Step 3: Putting It Together

Picture of Putting It Together

Following the schematics is pretty straightforward. The pictures below show the process, including the traces on the bottom of the little circuit board I used.

Step 4: Give It Power!

Picture of Give It Power!

Now you'll want to take your 12v adapter, and measure out the length of wire you want. The way I set it up, the little circuit board rests right on top of it when it's plugged in so the LED shines up the wall and gives the room a nice glow. Once you've got it at a good length, strip the wire a bit so you can easily solder it in place.

This is important! You'll want to make note of the polarity of each wire and where they go. The one with the white stripe is the positive and the solid black is the negative. Once you've established polarity, just wire it up according to the schematics.

[If you choose to add an on off switch, simply wire the switch between either the positive or negative wire and the board)]

Step 5: Plug It Up - You're Done!

Picture of Plug It Up - You're Done!

Plug it in and cover up the photo cell, unless you're in a dark room. The LEDs should come on! Whoooooo. Now you can just find a way of getting the board on top of the adapter. I drilled two holes in the top of the adapter and screwed it in place, but I can't say I recommend this :P Hot glue works just fine.


MiniKey (author)2017-01-01

Is there any way i could add a potentiometer to it so make it dimmable?

Rajvinderjitkaurs (author)2016-12-25

nice project

AjayM63 (author)2016-11-20


DavidB552 (author)2016-05-01

hey how many volts does this pull trying to work out a way to change to run of a solar recharged battiry ?

mienime2488 (author)DavidB5522016-05-03

Should be 12 VDC.

DavidB552 (author)mienime24882016-11-03


RachitK (author)2014-12-27

is there any alternative for the 2N4401 transistor, i can't find it in stores...

thanks in advance


JohnL8 (author)RachitK2014-12-28

The 2N4401 suggested is rated at 600mA Ic current. The LED in the picture consumes about 20mA at 3V. Even you use a high-power 1W LED, of course too bright for a night light, the LED will only consume about 280mA current. In case the LEDs connected are those small one rated at 20mA, you can use any small NPN transistor.

However, resistors value needed to adjust. For the transistor to turn on, the LDR (Photo Cell) has to establish a potential difference of 0.7V. With 12V power supply and 100kΩ resistor, the LDR will create 0.7V at roughly 6kΩ resistance. The transistor will only switch off in very bright environment. On the other hand, when 6V is used, the transistor will turn off when the resistance of the LDR drops to 12kΩ. Whether your circuit will work as expected depends on the specification of the LDR used.

This is what you need to do. Wait until the light intensity of your room drops to the level that you want the LED to turn on, measure the resistance of the LDR. Use this formula to calculate the value of the 100k resistor needed for your circuit.

Resistance of resistor = (Supplied Power x LDR Resistance) / 0.7

Assume LDR = 80kΩ, Power = 12V; Resistor = 80 x 12 /0.7 = 1371kΩ. Then you need to use a 1.3MΩ resistor in place of the 100kΩ shown in the circuit.

However, it creates another problem, with a 1.3MΩ resistor connected, the maximum base current will reduce to about 10uA, and a darlington transistor or two regular transistors are required to amplify the current to 20mA.

All in all, it's not an easy job. In case you really want to build this circuit, give me the measured resistance of the LDR decribed above and the supplied voltage you intend to use, I will then give you the circuit with all the correct component values. If you have some small transistor (NPN or PNP) already in hand, give me the numbers.

fugatecody (author)JohnL82016-04-11

Hello, im using a home made arduino to power an led matrix of about 120 leds. Anyways i would like to have the arduino shut off in light, on in night. I would like to set this up inbetween the 5 volt regulator and the atmega chip. Any idea what reaistance i should use so my atmega still works fine at night? ( its a 24x6 matrix for my 5 year old ). Thanks!

fugatecody (author)fugatecody2016-04-11

2N3904 TO-92 NPN General Purpose Transistor

fugatecody (author)fugatecody2016-04-11

Dark resistance(m):5
GL5516 LDR

AndrewB254 (author)RachitK2016-03-09

Use a 2n2222. Almost any PNP will work.

IshanFdo1 (author)2015-08-29

I want to use it on 6v power source. Please tell me which things i have to change.

AndrewB254 (author)IshanFdo12016-03-09

Play around with the resistors. You can probably replace the 1k with a 500ohm. Don't know for sure though

IshanFdo1 (author)AndrewB2542016-03-09

thanks for the reply after 6months :D

AndrewB254 (author)IshanFdo12016-03-09

Only reason I replied is because I stumbled across this tutorial while searching for a nightlight tutorial for a friend.


IshanFdo1 (author)AndrewB2542016-03-10

I made this for my 6v 500ma solar panel. It charges a small battery(4.2v about 1ah, so small) and I connected the circuit to my battery, but the led was not powerful enough. and the power draw when the light is in off state is too high. my battery didnt charge like it was used to without the circuit.

ghouse peer (author)2015-11-24

inst aide of LED'S we can connect '0'watt bulb

and inst dide of 12volts we can connect to AC 230volts

plese help me in this

AndrewB254 (author)ghouse peer2016-03-09

This is a DC circuit and relies upon Direct Current. Ac current flows in the form of a sine wave and as such would not work using this particular design. Also, the resistors are all 1/4 watt, you would need much larger watt resistors to power an ac bulb, and a much higher current photo resistor.

ailaG (author)2015-10-26

Two questions -

1. Will it work better with an old phone charger? (should be 5V DC)

2. What's the power consumption like? I built a similar circuit once, used cheap batteries and it finished them within a night. They're just cheap batteries, so I wasn't surprised, but I want to make sure I don't accidentally short something and discover it in the next bill.

(Yes, they're only LEDs, but there's always a way to screw something up)

AndrewB254 (author)ailaG2016-03-09

The circuit remains on even if it is emitting no light.
Consider using a 5v arduino power source.

gšapkinas (author)2015-05-18

thats realy nice :)

visskiss (author)2015-05-04

Could I use a five volt iPod charger for this project? What would I need to change? Thanks!

PRINCIPALB made it! (author)2015-01-18


PRINCIPALB made it! (author)2015-01-18


PRINCIPALB made it! (author)2015-01-18


PRINCIPALB made it! (author)2015-01-18


dociledragons (author)2014-11-16

This is what I was looking for but I need it to run 2-3 LED's using 120 AC Volts??? Anybody know how to do this??

bystrika (author)dociledragons2014-11-29

Capacitor does the trick.
Once you get it working, please share.

doctorxyz (author)2014-11-09

Manmeswar (author)2014-05-27

Hey the transistors very difficult to get as they are very rarely available. May i have options for any other alternative transistor?

Shortcircui (author)Manmeswar2014-09-05

Did you ever have Snapcircuits or a similar electronics kit?

they were also availbale in the uk, but a bit harder to find

screasy (author)2013-11-23

I made a similar project for my electronics class, but it uses a potentiometer to adjust the brightness/light sensitivity from to photocell, two red LEDs, similar resisitors, 9volt battery for power, and I created and etched my own board. All together it's inside a case with a battery snap I cut out of plastic. I can't add any photos right now because my teacher didn't grade it yet.

screasy (author)2013-11-23

I made a similar project for my electronics class, but it uses a potentiometer to adjust the brightness/light sensitivity from to photocell, two red LEDs, similar resisitors, 9volt battery for power, and I created and etched my own board. All together it's inside a case with a battery snap I cut out of plastic. I can't add any photos right now because my teacher has it.

islandboii242 (author)2013-05-09

Anyone know what changes i will need if i use 30+ LED's for this circuit? Does each LED require a 1k resistor coming from a 12v 1800 MaH Ni-Mi Battery?

cabor (author)2013-04-05

this circuit works great for my solar led windows
any one needs one solderd up let me know

agis68 (author)2009-07-21

usually the white striped cable in the packed adapters is the negative one...

Roaraar (author)agis682012-12-09

Of all the powerpacks I have worked with, all of them had solid black as negative, and white stripe as positive. Maybe you have a very unusual powerpack

Locutis (author)2009-04-03

I'm going to try to build this with 3 LR44 batteries instead of a 12V wall adapter. If it works I'll post it.

satpathi (author)Locutis2012-11-20

Any luck with 3LR44 batteries ?

pandyaketan (author)2012-05-08

Nice work! 

Issue of 3 leds:

The reason why you are not satisfied with results using 3 leds is because:

a) you should have trippled the resistor values - 3 1k resistors in series and three 100k in series or
b) you should have used "H bridge" to increase the sensitivity.

Alternative voltages:

a) AC Mains & EL wire:

Instead of using a 12v adaptor, you can use a diode bridge with capacitor (see my Instructables).

EL wire can be used effectively with my  diode bridge and capacitor power circuit along with your front end sensor circuit. 


You can also use an old plone charger, negative of the main circuit touches the outer side of the charging pin, while the positive of the circuit goes inside the pin. 

b) DC voltage:

you can also use 9V, 6v or other battery pack variations without changing the main parts of the circuit!

Hope it helps...


CivicSiR (author)2012-03-30

Thanks for sharing your design. I followed your method, but I'm using a 9V battery and 16 smd leds (it's a led for car dome rated at 12V). I got the photocell from ebay, but they don't seem to work as well. The leds only turn off when it's 10cm away from light source (i.e. yellow ccfl light or white led flash light).
What am I doing wrong here? Any way to increase the sensitivity of the photocell, so that it can turn off the leds with small amounts of light (clear sky during the day)?

Photocell specs:
size: 5.00x4.00mm
resistance on light: 5k-20k ohm
resistance in darkness: 1M ohm
max voltage: 150V (DC)
Peak sensitivity: 560nm



nodoubtman (author)2012-01-25

do you use 3 leds or 1 led?

thank you!

Thegame995 (author)2011-04-21


Do you know much much money it will cost me in electricity each month? Not exact, but is it expensive to have on like 7-8 hours a day? Does it use a lot of electricity? Thanks!

creatorroboto (author)Thegame9952011-06-08

Well, it it uses 12 volts so a nine volt battery in series with a 3 volt battery pack would work but an ac adapter shouldn't cost you too much...of course I not sure about the close count...

Thegame995 (author)2011-04-21

Could you please please please PLEASE! Upload a video where you do this? Im very new and I would like this to be my project! I really want this as I have the same PCB board! Please tell me a bit more detail/more pictures/a video!
Thanks for the instructable!

evilmadscientistman (author)2009-03-27

can someone help me, I can't seem to make it so that if its past the "dark" threshold it goes on and if its brighter that that it goes off it doesn't have just 2 solid states it has this big gray area were its only partly on.

You can also do this with the same el wire inverter that was mentioned above, from

You can add the light resister to the inverter to make this work.

dawisch (author)2011-02-14

I was wondering if it would be possible to setup something just like this but with EL wire instead of LED's.

I want a strip of blue EL wire going around the top of my room that turns on when the lights are off.

dawisch (author)dawisch2011-02-14

I looked into the EL wire a little and saw that they need inverters.

I found this one that runs at 12v:

So now my question is, could I simply remove the 1K resistor all together so that a full 12v from the wall outlet is flowing through then solder the inverter leads into the circuit instead of the LED? Or does their need to be a resistor there still?

About This Instructable




More by frostedminipete:LED nightlight that turns on in the dark
Add instructable to: