Home › Lessons › Op-amps and analog ICs › Comparator with a light sensor

Comparator with a light sensor

Op-amps and analog ICs · Intermediate · about 15 minutes · part of Zen’s Electronics Design Mastery

A comparator is an op-amp built for decisions: its output switches fully one way or the other depending on which input is higher. Here an LDR divider is compared with a threshold from a pot. When it gets dark, the divider voltage drops below the threshold and the LM393 turns the light on.

Comparator with a light sensor: the circuit on the simulator's bench

Open this lesson in the labFree, in your browser, no account needed.

How it works

Light signal: V− = 5 × 10k / (10k + RLDR) = 5 × 10k / (10k + 1.82 kΩ) = 4.232 V

Threshold: V+ = 5 × pot = 2 V

V+ < V−, so the open-collector output is pulled low, LED off.

Near the threshold, flicker or noise can make the output chatter. A large resistor from OUT to IN+ adds hysteresis (as in the Schmitt-trigger lesson).

Try it on the bench

  1. Click the LDR to cover it: dark, so the LED comes on.
  2. Select the LDR and set 20 lux (dusk): with the threshold at 40 % it is just bright enough to stay off. Turn the threshold pot up until it switches.
  3. Add a 100 kΩ resistor from OUT (pin 1) to IN+ (pin 3) for hysteresis, so it cannot flicker at dusk.

Parts on the bench

In the course

Zen’s Electronics Design Mastery, module “Op-Amps & Analog ICs”.

More on op-amps and analog ics