Erratic Voltage Readings from Analog Input

Hi everyone,

I’m currently working on a simple setup to count the interference fringes produced by an interferometer. There’s a photodiode positioned at the output, and when a bright fringe passes over it, it creates a voltage difference. The signal from the photodiode is passed into a comparator, and the output from this is sent to the A4 pin of an Arduino Nano.

When I measure all of the relevant voltages with a multimeter, it behaves exactly as I expect it should. However, the reading from the A4 pin is completely wrong and unresponsive. The numbers look the same as when I have nothing connected to it at all. When I tested it with a voltage divider, it read the voltages just fine, so it seems like the issue must be with my understanding of the circuit, rather than a hardware problem.

Please let me know if I need to provide any more information to help identify the issue. Thank you in advance for your help!

Code:

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


void loop() {
  int sensorValue = analogRead(A4);
  float voltage = sensorValue*(4.8/1023.0);  //measured max voltage is slightly below 5v

  Serial.println(voltage);
  delay(500);
}

That comparator can't work that way, because it has an open collector output.
You must add a (10k?) pull up resistor from the opamp's output to 5volt.

A comparator outputs a digital signal.
Don't know why you're trying to read it's analogue value with an analogue pin.

If you want an amplified analogue signal from your photo diode, then Google "transimpedance amplifier".
Leo..

Thank you for your help, Leo! I added a pull-up resistor and now it's working great. I had it on an analog pin because the voltage was below the 1.5V threshold for the digital pins, but now that the comparator is actually hooked up correctly, the output voltage is much higher. Thanks again!