I have two inputs for my LM393P comparator (https://www.rcscomponents.kiev.ua/datasheets/texas_instruments-lm393p-datasheet.pdf). I have checked these two inputs with the analog inputs with my Arduino Uno and they are typically at ~0.5v. I have 5v from the Arduino running to Vcc of the comparator and the ground of the comparator running to the Arduino ground. I am using input 1 of the comparator, having checked that I am using the correct input and output ports. The output port is connected to the Digital port 10 of the Arduino (set to "input") with a 1k resistor in between.

One thing I am concerned about, is that the marking on the comparator isn't the same as in the datasheet. The comparator does note it is the LM393P however, but I might have mistaken which side was "up". I believe it to be the side of the small circular indentation now.

The readings almost always return 1, but periodically return 0. These periodic readings seem to be separated with a almost fixed timing (~0.5s).

Having the comparator been placed in reverse, should I expect it to be broken or is there possibly another cause to my problem?

I'm not sure of a website or application in which I can draw schematics easily, as I am a beginner to electronics, but I'm willing to sketch a schematic if that's of use.

A picture of a part of my wiring


Just ordered some extra LM393's. I will keep this question open and check whether a new IC will fix the problem.


Made some new observations. I've got the LM393N's in the mail, and they show the same scenario. If I connect a led to the output, I see a faint light with a 100 Ohm resistor, while the same led on 5V input shows full brightness. Wiring digital ports to + and - inputs of the comparator and writing low and high, doesn't do anything either. I would expect the led to change in brightness. Is it required to use all the ports on the 393 comparator for it to work? To add some info, originally I was using photodiodes to compare the outputs of two of them and send the result to the Arduino.


I've tried replacing some of the connections to no avail.


I got the comparator working! I accidentally mistook delay() for being seconds, but it is instead milliseconds. Writing with the digital ports, high and low, alternated by a second, I got the comparator to play nice. I placed a 1K resistor between Vcc and output. Now to get it to work with my photodiodes..


It now works with my photodiodes, but the accuracy and responsiveness are very low.

  • \$\begingroup\$ Why is the other device floating? \$\endgroup\$ – Ignacio Vazquez-Abrams Aug 5 '15 at 19:00
  • \$\begingroup\$ Left side of the breadboard was used for another version . I guess that's what you're saying, I forgot to mention that. If you're talking about the other side of the comparator, I'm just using one side at the moment. \$\endgroup\$ – LongLog Aug 5 '15 at 19:05
  • \$\begingroup\$ Do you only have the one LM393P? It's always a good idea when building a new circuit/prototyping to buy at least two for when you make mistakes. If you connected it and powered it thinking pin 5 was pin 1 then you very well could have killed it. If you have another one, double check your connections and input voltages, and drop it in. \$\endgroup\$ – DigitalNinja Aug 5 '15 at 19:17
  • \$\begingroup\$ Okay, thanks for your input. I will order some extra indeed, unfortunately I only have the one at hand. I see that in the picture it is actually the wrong way around probably too. The circle in the left bottom corner of the chip should be on the right, I take it? \$\endgroup\$ – LongLog Aug 5 '15 at 19:24
  • \$\begingroup\$ The other comparator should be configured so that the output is high-impedance. \$\endgroup\$ – Ignacio Vazquez-Abrams Aug 5 '15 at 22:04

If your Arduino is reading both states, 0 and 1, your comparator may be OK. The problem is your inputs. They should not be "~0.5 volts". Instead, try a circuit like this


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ The LM393 can accept inputs down to the negative rail (and a bit beyond). \$\endgroup\$ – Kevin White Aug 6 '15 at 3:44
  • \$\begingroup\$ @KevinWhite - Sure, but that's not the point. This way gives well-defined input levels, and the operation of the comparator is clearly defined. In the OP, there was no specification of exactly what the levels were, and for all one knows the inputs were so close together that the comparator was responding to thermal drifts. \$\endgroup\$ – WhatRoughBeast Aug 6 '15 at 12:13
  • \$\begingroup\$ I've tried wiring up the digital ports to the input pins of the comparator, but that shows no decent results. \$\endgroup\$ – LongLog Aug 7 '15 at 19:40
  • \$\begingroup\$ Putting a 1K resistor between Vcc and output did the trick. \$\endgroup\$ – LongLog Aug 8 '15 at 7:08

The LM393 is an open collector device and will only pull down.

If you enable the internal pull-up in the Arduino it should work as that will pull the signal high when the LM393 is not conducting.

The 1K resistor is not necessary and you could connect it directly to the Arduino but it shouldn't hurt operation either so you can leave it there.

I can't see the pin 1 marker in the photo but you are right in that is often a small dimple next to pin 1.

  • \$\begingroup\$ Setting the internal pull up did not work unfortunately. I figure it must be that the IC is damaged. \$\endgroup\$ – LongLog Aug 5 '15 at 19:48
  • \$\begingroup\$ Update; IC isn't damaged. I ordered new ones and the same results apply. I've added a bit to the original post. \$\endgroup\$ – LongLog Aug 7 '15 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.