The open collector and the light
The LM393 can pull DIG down to GND and cannot push it up. A 10 kΩ resistor does that, to VCC, which is why VCC must be your board's logic voltage. The red LED runs from VCC onto DIG, so it lights only while DIG is LOW: lit means LOW, the opposite of the output.
Only down
The LM393's output is a transistor from the output pin to GND, and nothing else. When the comparator answers LOW, the transistor turns on and pulls DIG to within about 0.15 V of GND. When it answers HIGH, the transistor turns off and lets go. It cannot drive the pin up. That is an open collector: the name for an output that only ever pulls down.
So the board adds R12, 10 kΩ from DIG to VCC. Let go, DIG floats up to VCC through it, and your board reads HIGH. Pulled down, about a third of a milliamp from 3V3, half from 5V, flows through R12 into the chip, and your board reads LOW.
Why VCC is your board's voltage
HIGH on DIG is whatever VCC is. From 5V, DIG goes to 5 V, which is right for an Uno and too much for an ESP32, ESP32-S3 or Pico, whose pins are 3.3 V pins. So VCC goes to 3V3 beside those three and 5V beside an Uno. The block in the IN socket runs from the same VCC, and its SIGNAL, on ANA, can reach it too.
The light shows LOW
The red LED and its 1 kΩ resistor run from VCC to DIG. While DIG is HIGH, both ends of that pair are at VCC, nothing flows, and the LED is dark. While the comparator pulls DIG down, VCC is across them and the LED lights. So:
- LED lit: DIG is LOW.
- LED dark: DIG is HIGH, or the board has no power.
Worked out for a red LED at about 2.0 V, it takes about 1.2 mA from 3V3 and about 2.9 mA from 5V. With the pull-up, the comparator sinks about 1.5 mA and 3.3 mA, inside the datasheet's 6 mA minimum. None of that is measured, and the LED's brightness will differ a little between 3V3 and 5V.
What DIG can drive
HIGH is a 10 kΩ resistor, so DIG can supply only a fraction of a milliamp before it sags. That is plenty for a microcontroller's input, which takes almost nothing, and not enough for an LED, a buzzer or a relay. Read DIG with your board and drive the load from one of your board's own pins, as a light switch does.
When it does not work
Not from HIGH. HIGH is only the 10 kΩ pull-up, which can supply a fraction of a milliamp before the voltage sags. The comparator can sink a few milliamps when it pulls LOW, but the board's own LED and pull-up already use part of that. Drive loads from your board's pin, or through a transistor.
VCC is on 5V. DIG is pulled up to whatever VCC is, and the ESP32's pins are 3.3 V pins. Move VCC to 3V3. The comparator runs happily from 3.3 V; the datasheet's minimum is 2 V.
They agree. The LED lights while DIG is LOW, and 0 is LOW. The LED is wired from VCC to DIG, so it only has a voltage across it when the comparator pulls DIG down.
Why the top of the knob does not work, and what that means for a bright light sensor.
The input range →Edit this page — content/books/analog-to-digital-signal/the-open-collector-and-the-light.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Analog to Digital Signal
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.