Hi, I need some help to understand how is this working.

This is the source of my question.

My question is : why is the LED lighting up as it gets dark ? I taught that a LDR (light dependent resistor) is supposed to let current pass only when light is shining on it (source), so why here is it letting current pass only when it's dark. And what is the role of the transistor in this circuit ? Any clarification is much appreciated, Thank you.

Picture of Hi, I need some help to understand how is this working.
There isn't a clear circuit, but I think you can see that the BASE of the NPN transistor is fed by the LDR and 100K resistor. In the light condition, the voltage at the base of the transistor is kept low by the LDR. As it gets dark, and the LDR resistance climbs, the voltage on the base INCREASES, if enough current can flow through the 100K resistor, the LEDs will turn ON.
Eunix (author)  steveastrouk3 years ago
Thank you for answering my question in such a clear manner, this info is really helpful.
rickharris3 years ago
LDR is a low resistance when it is illuminated and a higher resistance when it is dark.

You need a transistor to switch the LED - the point of switching depends on the value of the resistor.
Night light.jpg
frollard3 years ago
Yes, light should lower the resistance and allow current to flow.

per that image, the BC548 transistor is Collector on the bottom, Base on the middle left and Emitter on the top.

Current flows from the battery, through the leds, then through the transistor (if allowed), then back to the battery.

The resistor and the LDR form a voltage divider, with the resistor pulling the base UP to almost 4.5 volts (which would cause the transistor to conduct) and the ldr pulling the base DOWN (to near zero volts (which would cause the transistor to turn off), when light is shone on it.

So: Pullup is always 100k
Pulldown LDR is either 100k (dark) or say...1k (light)

When dark, the transistor sees 4.5 volts (9 split in half) which causes the transistor to conduct, which turns the light on.

When light, the transistor sees 9v through 100k and 0v through 1k; which results in the transistor base getting 0.089V - not NEARLY enough to make it conduct, and the led goes off.

Basically, the transistor is INVERTING the signal from the LDR because the current passing effect of the LDR is inverted from what you want.