I'd like to use this circuit to detect low levels of light with a phototransistor and turn on an LED with a comparator (LM339). When the input voltage is higher than the reference voltage, it's supposed to connect the output pin to ground. Otherwise output should be an open connection.
But that's not how it's working in the actual circuit.
Input connected directly to ground, output open
Input connected pretty much anywhere in the circuit or even disconnected, output closed
vref disconnected, output closed
vref connected directly to ground or +5v, output closed
So the output is closed as long as the input isn't connected directly to ground...
I'm pretty sure the comparator isn't broken, because I tried 2 and have the same results. I think I'm just confused about how this comparator is supposed to be wired up.
The voltage divider produces 0.4-0.5mV, the phototransistor part produces around 0.7mV in my room. Around 25mV when I shine the flashlight on it.
The circuit was updated to remove the transistor I was using to amplify the output of the phototransistor, and the vref divider was updated accordingly (it's what the original image shows now).
But after updating it I have a different problem.
0 - connected directly to ground
1 - connected directly to vcc
Smajdalf:
0.7 mV over 1M resistor? Looks like something is wrong with the phototransistor.
I've got a bag of them, and they all produce around 1mV for the same light level.
Maybe the batch it defective? They give the same voltage regardless of resistance.
That's kind of irrelevant for the comparator though.
I was rewiring the circuit to remove jumper cables and move certain things closer together. When I noticed something. Without the vref connected, and with the phototransistor connected to the other input, it seems to work like I wanted it to. With vref connected again, it's always closed no matter what light levels are present.