I have;

1) 9 V dc source

2) two LEDs (red and green)

3) LDR

4) few resistors (kilo ohm)

5) npn transistor

I need to build a circuit such that the red LED lights up only at night (0 light intensity) and the green LED lights up only during the day (maximum light intensity).

How can I do this? I found out how to achieve the results for only one LED. The follwing is a rough sketch for the task at hand.

enter image description here

thank you

  • \$\begingroup\$ Think about the circuit for only one of LEDs first. Once you have that working, you can simply add a transistor in an inverter topology, so that it turns off when the first transistor turns on and vice-versa. Instead of having the LDR in series with the transistor base I would use it in the voltage divider, so that base-emitter voltage gets below or slightly above 0.6V as the light condition changes. \$\endgroup\$
    – joribama
    Commented Aug 3, 2019 at 4:59
  • \$\begingroup\$ is there a way I can do this by a single npn transistor? \$\endgroup\$
    – chan
    Commented Aug 3, 2019 at 6:03
  • \$\begingroup\$ see my answer below for the 1-transistor solution \$\endgroup\$
    – joribama
    Commented Aug 3, 2019 at 7:09

1 Answer 1


If you really want a solution with only one transistor, take a look at the circuit below.

R1 and R2 values can be the same, so that these two resistors are equivalent to a 4.5V supply with some series resistance. The idea is that when Q1 is off, the LEDs are polarized between 9V on the bottom and 4.5V on top, what makes D2 turn on. When Q1 is on, then the LEDs are polarized with 4.5V on top and zero volts on the bottom, what makes D1 turn on.

Q1 is normally on in darkness thanks to R4. When light is present, LDR1 drops the base voltage below 0.6V turning Q1 off.

It's not the most elegant circuit I've created, but it may work ;).


simulate this circuit – Schematic created using CircuitLab


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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