Loading simulator…
A dark environment should switch on an LED without software. A light-dependent divider controls the base of an NPN transistor, which supplies the LED current only when illumination is low.
R_PULL = 15 kΩ from VCC = 5 V to the base-control node. The supplied LDR1 connects that node to ground.Q1, letting it sink current from the LED branch.R_LED = 470 Ω in series with the supplied red LED1 from VCC to Q1's collector. With the transistor saturated, approximate LED current is , inside the 5–10 mA requirement at 20 lux.LDR1 falls in resistance and pulls the transistor base toward ground. At 200 and 500 lux, Q1 remains off and LED current must be below 0.1 mA.Set LDR1 to 20, 200, and 500 lux. Check LED current of 5–10 mA in the first case and below 0.1 mA in both brighter cases. As an experiment, change R_PULL to shift the effective darkness threshold.