The LM393 is a dual differential voltage comparator in an 8-pin package. It contains two independent comparators that share one supply, operate from 2 V to 36 V single-supply (or ±1 V to ±18 V split), and switch an open-collector output when one input voltage crosses the other. Introduced by National Semiconductor and now produced by TI, onsemi, STMicroelectronics, and several other manufacturers, it is the standard low-cost part for threshold detection: voltage monitoring, sensor interfaces, zero-crossing detection, and the digital-output stage on most Arduino sensor modules.
The LM393 is a comparator, not an op-amp. Its inputs look identical to an op-amp’s, but the output stage is a bare NPN transistor with no internal pull-up, and the device is designed to run saturated, not linear. Both facts drive most of the practical design decisions below.
LM393 Pinout
All 8-pin packages — PDIP-8, SOIC-8, TSSOP-8, and VSSOP-8 — use the same pin assignment.

| Pin | Name | Function |
|---|---|---|
| 1 | OUT1 | Comparator 1 output, open collector |
| 2 | IN1− | Comparator 1 inverting input |
| 3 | IN1+ | Comparator 1 non-inverting input |
| 4 | GND | Ground (V− on split supply) |
| 5 | IN2+ | Comparator 2 non-inverting input |
| 6 | IN2− | Comparator 2 inverting input |
| 7 | OUT2 | Comparator 2 output, open collector |
| 8 | VCC | Positive supply, 2 V to 36 V |
This is the same pin map as the LM358 dual op-amp. The two parts are pin-compatible but not interchangeable — the difference is covered in the comparison section below.
TI’s LM393B revision adds a SOT-23-8 (DDF) package option with the same pin assignment.
LM393 Datasheet: Key Specifications
Values below are for the standard commercial LM393 at 25 °C; manufacturers’ figures agree within normal tolerance. The controlling document for TI parts is the LM393B/LM393 datasheet.
| Parameter | Value |
|---|---|
| Supply voltage (single) | 2 V – 36 V |
| Supply voltage (split) | ±1 V – ±18 V |
| Supply current (per package, typ.) | 0.4 mA, independent of supply voltage |
| Input offset voltage | ±2 mV typ., ±5 mV max |
| Input bias current (typ.) | 25 nA |
| Input common-mode range | 0 V to VCC − 1.5 V (includes ground) |
| Response time (typ.) | 1.3 µs |
| Output type | NPN open collector, rated to 36 V |
| Output sink current | 16 mA typ., 6 mA min |
| Output saturation voltage (typ.) | 150 mV at 4 mA sink |
Two of these lines explain why the LM393 is the default comparator for single-supply circuits. The common-mode range includes ground, so it can compare signals sitting at 0 V without a negative rail. And the output’s 36 V rating is independent of the supply pin, which allows the output to be pulled up to a different voltage than VCC — the basis of the level-shifting trick described below.
Temperature Grades: LM193, LM293, LM393, LM2903
The four base part numbers are the same die specified over different temperature ranges:
| Part | Operating range | Grade |
|---|---|---|
| LM193 | −55 °C to +125 °C | Military |
| LM293 | −25 °C to +85 °C | Industrial |
| LM393 | 0 °C to +70 °C | Commercial |
| LM2903 | −40 °C to +125 °C | Automotive |
TI’s 2019 “B” revisions (LM393B, LM2903B) tighten the maximum input offset voltage to ±2.5 mV and extend the LM393B rating to −40 °C to +125 °C, making the historical grade split largely irrelevant for new designs on TI silicon. Other manufacturers continue to ship the classic grades.
The Open-Collector Output: Why a Pull-Up Resistor Is Required
The single most common LM393 mistake is wiring it like an op-amp and finding the output stuck low or floating. The output pin connects internally to the collector of an NPN transistor whose emitter is tied to ground. The device can therefore only sink current — pull the pin toward ground. It cannot source current or drive the pin high. A logic-high state must come from an external pull-up resistor.

The logic works out as follows:
- IN+ above IN− → output transistor off → the pin is high-impedance, and the pull-up resistor takes it to the pull-up rail.
- IN+ below IN− → output transistor on → the pin is pulled to within ~150 mV of ground.
Without the pull-up, the “high” state is simply a floating pin: a multimeter may read an ambiguous voltage, a microcontroller input will read noise, and the circuit appears to half-work — which is exactly why the fault is hard to recognize the first time.
Sizing the pull-up. The value trades switching speed against wasted current. A small resistor (1 kΩ at 5 V) gives fast rising edges but burns 5 mA through the output transistor in the low state — a third of the typical 16 mA sink capability, and a real cost in battery circuits. A large resistor (100 kΩ) saves current but forms a slow RC with trace and input capacitance, rounding the rising edge. For 5 V logic, 1 kΩ–10 kΩ covers almost every case; 10 kΩ is the default when nothing argues otherwise.
Level shifting for free. Because the output rating (36 V) is independent of VCC, the pull-up does not have to go to the comparator’s own supply. An LM393 running from 12 V can have its output pulled up to 3.3 V and drive a microcontroller input directly — no level-shifter IC needed. The same property allows multiple open-collector outputs to be tied to one pull-up, producing a wired-AND: the shared line is high only when every comparator releases it.
How the Comparator Works
A comparator answers one question — is the voltage on IN+ higher than the voltage on IN−? — and expresses the answer as a two-state output. In the basic detector above, a 10 kΩ/10 kΩ divider puts a 2.5 V reference on IN−, and the monitored signal drives IN+. The output switches each time the signal crosses 2.5 V. The reference can equally come from a Zener, a voltage reference IC, or a trimmer when the threshold must be adjustable.
Internally the LM393 is a high-gain differential stage running open-loop: a few millivolts of input difference is enough to drive the output transistor fully on or fully off. There is no feedback network holding the device in its linear region, which is precisely what separates it from an op-amp and what makes its 1.3 µs response time possible on 0.4 mA of supply current.
Unused comparator. Single-threshold circuits leave one of the two comparators idle. Do not leave its inputs floating — an undefined input can cause the spare channel to oscillate and inject noise into the shared supply. Tie IN+ to ground and IN− to a resistor divider (or IN− to ground and IN+ to a mid-rail point); either way, force a defined output state. Better still, put it to work: the window comparator below uses both halves.
Adding Hysteresis to Stop Output Chatter
The basic detector has a real-world failure mode: when a slow or noisy signal sits near the threshold, the output chatters — switching rapidly back and forth as noise carries the input across the trip point repeatedly. A microcontroller counting those edges sees dozens of events for one physical crossing.
The fix is hysteresis: a small amount of positive feedback that moves the threshold away from the input each time the output switches, creating two trip points instead of one.

With the input fed through Rin (10 kΩ) and a feedback resistor Rf (470 kΩ) from the output node back to IN+, the hysteresis width is approximately:
V_hys ≈ VCC × Rin / (Rin + Rf) = 5 V × 10k / 480k ≈ 104 mV
The comparator now trips at roughly 2.55 V on a rising input and 2.45 V on a falling one. Noise smaller than the 100 mV window can no longer retrigger the output. Widen the window by lowering Rf; narrow it by raising Rf.
One open-collector caveat: the feedback voltage in the high state comes through the pull-up resistor, so Rpu is effectively in series with Rf during half the cycle, and the low state sits at ~150 mV rather than 0 V. The result is mildly asymmetric thresholds. For a threshold detector this rarely matters; keep Rf at least ten times Rpu so the pull-up’s contribution stays small, and calculate exactly only when the trip points themselves are the specification.
Application Circuit: Dark-Activated Switch
The classic LM393 application joins everything above: a resistive sensor divider on one input, an adjustable reference on the other, and the open-collector output sinking a load directly.

An LDR and a 10 kΩ resistor form a light-dependent divider into IN+. A 10 kΩ trimmer sets the reference on IN−. In bright light the LDR’s resistance is low, IN+ sits above the reference, the output transistor is off, and the LED stays dark. As light falls, the LDR’s resistance climbs, IN+ drops below IN−, the output transistor turns on, and the LED lights — its current flowing from VCC through the 330 Ω resistor into the output pin.
Note that this circuit needs no pull-up: the LED and its resistor are the load, and the open collector switches it on the low side. Keep the sunk current inside the output rating — 330 Ω at 5 V puts roughly 9 mA through a red LED, comfortably under the 16 mA typical sink limit. For heavier loads (relays, lamps), the output drives the base of an external transistor instead, and the same topology scales to any current the external transistor can handle.
Swapping the LDR and R1 positions inverts the behavior into a light-activated switch; substituting a thermistor turns the same circuit into an over- or under-temperature alarm. Every variant is the same three blocks: sensor divider, reference, comparator.
Window Comparator: Using Both Halves
The dark switch uses half the package. The circuit that justifies buying a dual comparator is the window comparator: one comparator watches an upper limit, the other a lower limit, and together they answer whether a voltage sits inside an acceptable band — the standard topology for battery-voltage monitoring, supply supervision, and go/no-go testing.

A three-resistor string sets the two thresholds — with three equal 10 kΩ resistors on 5 V, the window runs from 1.67 V to 3.33 V. The input drives comparator A’s inverting input against the upper threshold and comparator B’s non-inverting input against the lower one. While the input stays inside the window, both output transistors are off and the shared pull-up holds the line high. The moment the input leaves the window in either direction, one of the two transistors turns on and pulls the line low.
The detail worth noticing is the output wiring: both open-collector outputs connect to a single pull-up resistor. This is the wired-AND connection from the pull-up section in practice — either comparator can assert the line low, and the line reads high only when both release it. A push-pull output stage (an op-amp, or a CMOS comparator with a totem-pole output) cannot be paralleled this way; two push-pull outputs fighting each other would short the supply. The open collector that costs a pull-up resistor in every simple circuit is what makes this two-chip-into-one-wire logic free.
The LM393 in Arduino Sensor Modules
Search interest in the “LM393 sensor” comes almost entirely from one place: the marking on low-cost sensor modules. IR obstacle-avoidance boards, slotted speed/encoder sensors, sound-detection boards, soil-moisture probes, and flame sensors mostly carry the same back-end — an LM393 comparing the raw sensor voltage against a reference set by the onboard trimmer.
Reading such a module is straightforward once the schematic above is recognized:
- AO (analog out), where present, is the raw sensor divider voltage, taken before the comparator.
- DO (digital out) is the LM393 output — a clean high/low that any 3.3 V or 5 V microcontroller pin can read.
- The trim pot does not adjust “sensitivity” in any analog sense; it sets the reference voltage on the comparator’s other input, i.e. the threshold at which DO flips.
- The onboard LED on DO indicates the comparator state, which makes threshold calibration a matter of turning the pot until the LED flips at the desired condition.
Connecting a module to an Arduino takes three wires — VCC to 5 V (or 3.3 V), GND to GND, DO to any digital pin — and reading it takes one function call:
const int DO_PIN = 2;
void setup() {
pinMode(DO_PIN, INPUT); // the module carries its own pull-up
Serial.begin(9600);
}
void loop() {
if (digitalRead(DO_PIN) == LOW) { // most modules pull DO low on detection
Serial.println("Triggered");
}
delay(50);
}
Two module-specific checks before trusting the code: confirm the active level, since most boards assert DO low on detection (the open-collector transistor turning on) but some add an inverting stage — the onboard LED tells you in seconds; and set the threshold with the trimmer while watching that LED, not by editing code, because the trip point lives in the comparator’s reference voltage, not in the sketch.
The LM393 owns this niche for the same reasons it appears everywhere else: a few cents per unit, true single-supply operation down to well below 3.3 V, and an output that interfaces with any logic family through nothing but a pull-up.
LM393 vs LM339, LM2903, and LM358
LM393 vs LM339. Electrically the same comparator; the LM339 packs four of them into a 14-pin package while the LM393 carries two in 8 pins. Choose by channel count and board space — a window comparator plus one more threshold pushes the design to an LM339, while a single-threshold circuit wastes half of even the LM393. Specifications, open-collector behavior, and design rules carry over unchanged.
LM393 vs LM2903. The same dual comparator specified for −40 °C to +125 °C. For automotive or outdoor-industrial designs, the LM2903 (or its AEC-Q100-qualified LM2903-Q1 variant) is the drop-in choice; nothing else about the circuit changes.
LM393 vs LM358 — pin-compatible, not interchangeable. This substitution deserves its own warning because the parts share a pinout, and swapping one for the other produces circuits that almost work. The LM358 is a dual op-amp with a push-pull output that both sources and sinks current and needs no pull-up; the LM393 is a comparator whose open collector only sinks. Drop an LM393 into an amplifier socket and the negative-feedback loop has no way to pull the output up — the circuit cannot operate linearly at all. Drop an LM358 into a comparator socket and it will function, but poorly: an op-amp driven to its rails takes tens of microseconds to recover from output saturation, versus the LM393’s 1.3 µs response, and the LM358’s output cannot participate in wired-AND or pulled-up level-shifting. Use each part for the job its output stage was built for.
LM393 vs LM311. The LM311 is a single comparator with a heavier output stage (50 V / 50 mA) plus strobe and offset-balance pins. It suits one-channel designs driving relays or lamps directly; the LM393 wins on channel density, supply current, and simplicity.
Manufacturer Versions and Part Number Suffixes
The LM393 is a multi-source jellybean: TI (which absorbed originator National Semiconductor), onsemi, and STMicroelectronics all run it as an active catalog part, and Taiwanese and Chinese manufacturers such as UTC produce compatible versions. The core specifications match across sources; the suffix systems do not, and the suffix is what actually determines the package and packing on a purchase order.
| Ordering number | Manufacturer | Package | Packing |
|---|---|---|---|
| LM393P | TI | PDIP-8 | Tube |
| LM393DR | TI | SOIC-8 | Tape & reel |
| LM393PWR | TI | TSSOP-8 | Tape & reel |
| LM393BIDR | TI | SOIC-8 (“B” revision) | Tape & reel |
| LM393NG | onsemi | PDIP-8 | Rail |
| LM393DR2G | onsemi | SOIC-8 | Tape & reel |
| LM393DMR2G | onsemi | Micro8 | Tape & reel |
| LM393N | ST | DIP-8 | Tube |
| LM393DT | ST | SO-8 | Tape & reel |
Common decode rules: TI’s trailing R means tape and reel and PW means TSSOP; onsemi’s trailing G marks Pb-free and 2G a 2,500-piece reel; ST’s T suffix likewise indicates tape and reel. For automotive builds, look for the Q1 (TI) or AEC-qualified LM2903 derivatives rather than a commercial LM393 suffix.
For BOM substitution across manufacturers, the base part is safely multi-sourced — an ST LM393DT and an onsemi LM393DR2G land on the same SOIC-8 footprint with the same electrical behavior. The one revision worth flagging in a cross-reference is TI’s B version, whose tighter offset spec and wider temperature range exceed, rather than merely match, the classic part.
