I have made, what I thought would be a simple circuit, an LED night light. The power source is 5V@1A. The schematic is below:


simulate this circuit – Schematic created using CircuitLab

The intended goal is to increase the brightness of the LED, as light decreases. The LED should be completely off when the light level is high. When I built the circuit, I was very surprised to find out that it functioned in the COMPLETE OPPOSITE way. When I pointed the LDR towards a light source, it increased the brightness of the LED as it turned closer to the light source. If I put my finger on the LDR so that almost no light can enter, the LED looks as if it is completely off. Why is this happening? I suspect it has something to do with the voltage divider, whose output is connected to the base of the 2n3904.

I have calculated the value of R1 using the voltage divider equation. I will post my calculations soon(within the next couple of hours), my final result of the inequality that I solved(will post my steps soon)is 1kΩ

I tested the LDR and here is how the resistance changes in different cases: 1.Almost complete darkness-0.83MΩ 2.Dark-0.44MΩ 3.In between-8.66KΩ 4.Kind of Bright- 2.45kΩ 5.Bright-1.23kΩ 6.Very bright-1.21kΩ

The LED has a forward voltage drop of 2V. The peak brightness of the LED is achieved with a current of 9.09mA.

In case 1, full brightness of LED should be achieved. In case 2. Half brightness of LED should be achieved In case 3.Very little emission from the LED. In cases 4-6, the LED should be off.

It seems as if my calculation(which I will post soon) for the fixed resistor of the light dependent voltage divider is wrong. How do I calculate R1 correctly.Sorry if my question is a bit vague, if you need any details please ask. Thanks.

Edit: The positions of the LDR and R1(the 1.1k resistor) are now switched in the actual circuit. After doing this, the LED is always on. I will calculate the value of R1 again.

  • \$\begingroup\$ Oh, and I did find a similar question where the fixed resistor was 2.2kohms, and it supposedly worked. I do not know how this value was calculated though, which is my question. How is R1 calculated? \$\endgroup\$ – zack1544 Dec 30 '16 at 22:11
  • 1
    \$\begingroup\$ The circuit as drawn above can't possibly work. Please post the actual circuit you are using. \$\endgroup\$ – Peter Bennett Dec 30 '16 at 22:15
  • 4
    \$\begingroup\$ The LDR and fixed resistor need to change places for the circuit to work like you want. The resistor value may need to change as well, and you will have to check the beta of the transistor to see if you have enough current gain. \$\endgroup\$ – John D Dec 30 '16 at 22:29
  • 4
    \$\begingroup\$ @zack1544: It is conventional to draw the positive supply line at the top of the schematic, and the negative at the bottom. If the LDR and R1 were drawn vertically, one above the other, the fact that they make a voltage divider would be more evident. For clarity, the LED and R2 should be above the transistor collector. Drawing things this way makes it easy for the reader to understand the circuit at a glance, without having to trace wires all over the place. \$\endgroup\$ – Peter Bennett Dec 30 '16 at 22:35
  • 1
    \$\begingroup\$ @zack1544 Have a look at the bottom of my answer to someone else's similar question: electronics.stackexchange.com/questions/265195/… \$\endgroup\$ – jonk Dec 31 '16 at 4:20

JohnD is correct: the LDR and R1 need to be interchanged for the circuit to work as you want. Assuming you interchange the LDR and R1 (the LDR should be connected from the transistor base to emitter), here's a way to calculate the required value of R1:

Let's say the the LED should turn off for a condition somewhere in between Case3 (LDR= 8.6kΩ) and Case4 (LDR= 2.5kΩ). Let's choose LDR=5kΩ as a suitable condition. For this condition, the base voltage of the transistor should be approximately at the turn-on Vbe (about .6V from the 2N3904 datasheet available here http://www.jameco.com/Jameco/Products/ProdDS/783421.pdf). So Vout= .6 = 5* LDR/(LDR+R1) = 5* 5k/(5k+R1). Solving for R1 gives R1~36kΩ.

Next we should check how much current can be supplied to the LED in full darkness: In full darkness, the LDR resistance is very high, and approximately an open circuit. R1 will therefore supply the entire base current, calculated as Ib = (5-.6)/R1 = 122 µA. With a transistor gain of ~70, this would result in a maximum collector current through the LED of app 8.5 mA. This may be enough for a nightlight LED. If you find the LED is not bright enough, then using two transistors in a Darlington arrangement would provide a much higher current gain and thereby allow more LED current.

  • \$\begingroup\$ AndyW whoops...I accepted this answer a few weeks ago, but I didn't work on the circuit since then. Thank you for your answer, will try. \$\endgroup\$ – zack1544 Jan 19 '17 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.