LM393: Dual Comparator Explained

The LM393 is a dual voltage comparator that is widely used in sensor circuits, voltage monitoring, signal processing, and microcontroller-based applications. It allows you to compare two voltages and output a digital HIGH or LOW signal based on the comparison.


๐Ÿ”น 1. What is LM393?

  • LM393 is a dual comparator, meaning it has two independent voltage comparators inside a single package.
  • Unlike an operational amplifier (Op-Amp), it is designed specifically for fast voltage comparison.
  • Outputs either HIGH (logic 1) or LOW (logic 0), making it ideal for microcontroller interfacing.

๐Ÿ“Œ Key Features:

  • Dual comparators in one package (can compare two separate voltage pairs).
  • Open-collector output (allows interfacing with different voltage levels).
  • Low power consumption.
  • Can operate from a single power supply (2V – 36V).
  • Fast response time (~1.3ยตs switching speed).

๐Ÿ“Œ Common Applications:

  • Zero-crossing detection (detects when a signal crosses 0V).
  • Overvoltage and undervoltage protection.
  • Analog-to-digital conversion (ADC) circuits.
  • IR sensors, motion detectors.
  • Battery level monitoring.

๐Ÿ”น 2. LM393 Pinout & Functions

The LM393 comes in an 8-pin DIP/SOIC package.

Pin No.NameFunction
1OUT1Output of Comparator 1
2IN1-Inverting Input (-) of Comparator 1
3IN1+Non-Inverting Input (+) of Comparator 1
4GNDGround (0V)
5IN2+Non-Inverting Input (+) of Comparator 2
6IN2-Inverting Input (-) of Comparator 2
7OUT2Output of Comparator 2
8VCCPower Supply (2V – 36V)

๐Ÿ“Œ How it works:

  • Each comparator compares two voltages (IN+ and IN-).
  • If IN+ > IN-, the output is LOW (0V).
  • If IN- > IN+, the output is HIGH (open-collector, needs a pull-up resistor).

๐Ÿ”น 3. How LM393 Works

  • The LM393 outputs a digital HIGH or LOW based on the voltage difference between IN+ and IN-.
  • Unlike Op-Amps, the output is open-collector, meaning it requires a pull-up resistor to function properly.

๐Ÿ“Œ Logic Table for LM393 Comparator:

ConditionOutput (OUTx Pin)
IN+ > IN-LOW (0V, sinks current)
IN+ < IN-HIGH (Needs pull-up resistor to VCC)

๐Ÿ”น 4. Using LM393 for a Sensor Circuit

๐Ÿ›  Required Components

  • 1x LM393 Comparator
  • 1x LDR (Light Dependent Resistor)
  • 1x 10kฮฉ Resistor (Pull-down)
  • 1x 100kฮฉ Resistor (Reference Divider)
  • 1x LED + 330ฮฉ Resistor (Output Indicator)
  • 1x 5V Power Supply
  • Jumper Wires

๐Ÿ›  Wiring

LM393 PinConnection
VCC (Pin 8)+5V
GND (Pin 4)GND (0V)
IN1+ (Pin 3)LDR voltage divider output
IN1- (Pin 2)Reference voltage (via 100kฮฉ resistor)
OUT1 (Pin 1)LED + 330ฮฉ Resistor to VCC

๐Ÿ“Œ How it works:

  • When LDR detects bright light, IN+ voltage increases above IN-, and the output goes LOW (LED OFF).
  • When LDR detects darkness, IN+ drops below IN-, and the output goes HIGH (LED ON).

๐Ÿ”น 5. Arduino Code for LM393 (Reading Output)

This code reads the output of LM393 and prints the light level.

#define SENSOR_PIN 7  // LM393 output connected to Arduino D7

void setup() {
    pinMode(SENSOR_PIN, INPUT);
    Serial.begin(9600);
}

void loop() {
    int state = digitalRead(SENSOR_PIN);
    if (state == LOW) {
        Serial.println("Bright Light Detected");
    } else {
        Serial.println("Darkness Detected");
    }
    delay(500);
}

๐Ÿ“Œ What happens?

  • When it’s bright, the output is LOW (0V) โ†’ The Arduino detects “Bright Light Detected”.
  • When it’s dark, the output is HIGH โ†’ The Arduino detects “Darkness Detected”.

๐Ÿ”น 6. LM393 for Battery Level Monitoring

๐Ÿ“Œ Can be used to monitor battery voltage and trigger alerts when voltage drops below a threshold.

โœ… Example: Low Battery Indicator

LM393 PinConnection
VCC (Pin 8)Battery Positive
GND (Pin 4)Battery Negative (0V)
IN1+ (Pin 3)Voltage Divider (Battery Voltage Sampling)
IN1- (Pin 2)Fixed Reference Voltage (Zener or Resistor Divider)
OUT1 (Pin 1)Connects to LED or Microcontroller for alert

๐Ÿ“Œ If battery voltage drops below threshold, LM393 output goes HIGH, triggering an alert.


๐Ÿ”น 7. Applications of LM393

โœ… Light Sensing (LDR Circuits) โ€“ Used for automatic street lights.
โœ… Zero-Crossing Detection โ€“ Detects when AC voltage crosses 0V.
โœ… Overvoltage/Undervoltage Protection โ€“ Prevents damage to circuits.
โœ… DC Motor Speed Monitoring โ€“ Used in tachometers.
โœ… Touchless IR Sensors โ€“ Common in motion detection systems.


๐Ÿ”น 8. LM393 vs Other Comparators

FeatureLM393LM358 (Op-Amp)LM339 (Quad Comparator)
Number of Comparators22 (Op-Amps, not true comparators)4
Operating Voltage2V โ€“ 36V3V โ€“ 32V2V โ€“ 36V
Output TypeOpen-CollectorPush-PullOpen-Collector
Best ForLogic-level voltage detectionAnalog amplificationMulti-channel voltage comparison

๐Ÿ“Œ Verdict:

  • LM393 is ideal for digital-level voltage comparisons (requires pull-up resistor).
  • LM358 is an Op-Amp, better for analog signal amplification.
  • LM339 is a quad comparator (similar to LM393 but with four comparators).

๐ŸŽฏ Conclusion

  • LM393 is a dual voltage comparator with an open-collector output.
  • Used in light sensing, battery monitoring, zero-crossing detection, and voltage protection.
  • Requires a pull-up resistor for output.
  • Ideal for microcontroller-based applications (low power, fast switching).
๐Ÿ“กBroadcast the signal โ€” amplify the connection.

Leave a Reply