ToolSphere
All perfboard layouts

LM358 Dark Sensor LED Perfboard Layout

A slow light-versus-reference comparison turns on an LED in darkness. The isolated-pad layout is schematic-verified, not prototype-tested; it is not a calibrated lux sensor.

LM358 dark-activated LED perfboard layoutJ1 5VJ2 LDRU1 LM358R1 10kR2 10kR3 20kR4 10kR5 4k7R6 100kR7 1kQ1 2N3904D1 LEDC1 100n
Open this layout in the simulator Connection check: no shorts, 10 named nets

Red wires carry power, white is ground, yellow and blue are signals. Every hole is an isolated pad; connections are the wires shown. In the simulator you can move parts, add your own and re-run the check.

Parts list

As an Amazon Associate, ToolSphere earns from qualifying purchases.

How it works

J2 connects an external LDR, with no invented mechanical LDR footprint. The upper divider branch is a fixed 10 kΩ resistor plus the LDR; the lower branch is 10 kΩ. With a 5 V supply, the resistor library gives 2.381 V at a sample LDR resistance of 1 kΩ and 0.417 V at a sample 100 kΩ. These resistance points are assumptions, not universal bright/dark specifications for a particular photoresistor.

The fixed series resistor limits the sense voltage to 2.5 V even if the LDR resistance approaches zero. This matters because a classic LM358’s input common-mode range does not extend to its positive supply. The reference divider uses 20 kΩ above 10 kΩ, giving 1.667 V. Both inputs stay away from the positive rail in this nominal design. Check your actual LM358 variant’s pinout and electrical limits.

The reference goes to the noninverting input, and the light-sensitive voltage goes to the inverting input. Darkness increases the LDR resistance and lowers the sense voltage below the reference, driving the output high. That output drives the 2N3904 through 4.7 kΩ. The emitter is grounded, the collector switches the LED, and a 100 kΩ base pulldown defines the off state.

Assuming a 2 V LED drop and 0.2 V collector-emitter saturation drop, the 1 kΩ LED resistor gives 2.8 mA. At an explicitly assumed 2.5 V op-amp high level and 0.7 V base-emitter drop, the switch library computes 0.383 mA through the fitted base resistor, before the 0.007 mA pulldown current. This exceeds the nominal forced-beta-10 requirement of 0.280 mA for that LED current. It is a component calculation, not a guaranteed LM358 output swing under every load and temperature; check the actual device.

The unused amplifier is connected as a ground-referenced follower, with its output joined to its inverting input and its noninverting input grounded. Its inputs do not float. This circuit deliberately has no hysteresis, so an LED near the threshold can flicker. An LM358 used open-loop is appropriate only for this slow demonstration, not a substitute for a fast comparator. Use isolated pads and insulated jumpers; there are no stripboard cuts.

Building it, step by step

  1. Fit the DIP socket and NPN, verifying the actual package pin orders. Wire the supply, ground and local bypass capacitor.
  2. Wire 10 kΩ from +5V to the LDR header top, then the LDR bottom to SENSE and another 10 kΩ from SENSE to ground.
  3. Build the 20 kΩ/10 kΩ reference divider. Connect REFERENCE to IN1+ and SENSE to IN1−.
  4. Connect OUT1 through 4.7 kΩ to the transistor base and fit its pulldown. Wire the LED with a separate 1 kΩ series resistor.
  5. Connect the unused amplifier as the shown follower. Check continuity unpowered, then cover the LDR and observe the LED; measure both comparator inputs if it behaves unexpectedly.

Tools for this build

Frequently asked questions

Why is a fixed resistor in series with the LDR?

It keeps the sense voltage below midrail even in strong light. The LM358 input is not allowed to swing freely up to its positive rail in this design.

Why does the LED turn on in darkness?

Darkness raises the LDR resistance and lowers the sense input. The fixed reference is on the positive input, so the output goes high when sense falls below it.

Why can the LED flicker near the threshold?

There is no hysteresis. Small light or supply changes near the crossing can switch the output repeatedly; a Schmitt-trigger design is needed for a cleaner threshold.

Does this measure lux?

No. The resistance examples are assumed operating points, and real LDRs vary. It is an uncalibrated threshold demonstration rather than a light meter.