user2881: I'm trying to detect light using an led that's already attached to the circuit. I have a flashlight shining on the led.
Minimal sketch:
while( true )
{
    int photoValue = 0;
    analogReference(INTERNAL);
    photoValue = analogRead(A5);

    Serial.println(photoValue);

    delay(300);

}

While I have my multimeter attached, it reads a pretty constant value around 5mV. The serial output however swings around, as seen in this sample output:
0
0
4
4
0
16
15
22
21
25
20
36
40
34
36
24
5
0
3
6
0
0
0
0

That would translate to values between 0 and 43mV.
When I disconnect the multimeter only get 1023 printed.
I don't get how the values from the ADC and the multimeter, totally don't match.

user4143: The problem you are facing is that the output of the LED is too high impedance for the ADC to work reliably.
Basically the LEDs can't produce enough current to charge the S&H capacitor properly, and on top of that the LED doesn't act as a resistive load when not forward biased, so the input is basically floating and picking up noise.
The best cure is to add a voltage-follower buffer with incredibly high input impedance in front of the ADC input.
By high impedance I mean something measured in the 10s to 100s of TΩ. Something like the OPA355.

2881: <p>I'm trying to detect light using an led that's already attached to the circuit. I have a flashlight shining on the led.</p>

<p>Minimal sketch:</p>

<pre><code>while( true )
{
    int photoValue = 0;
    analogReference(INTERNAL);
    photoValue = analogRead(A5);

    Serial.println(photoValue);

    delay(300);

}
</code></pre>

<p>While I have my multimeter attached, it reads a pretty constant value around 5mV. The serial output however swings around, as seen in this sample output:</p>

<pre><code>0
0
4
4
0
16
15
22
21
25
20
36
40
34
36
24
5
0
3
6
0
0
0
0
</code></pre>

<p>That would translate to values between 0 and 43mV.</p>

<p>When I disconnect the multimeter only get <code>1023</code> printed.</p>

<p>I don't get how the values from the ADC and the multimeter, totally don't match.</p>
 4143: <p>The problem you are facing is that the output of the LED is too high impedance for the ADC to work reliably.</p>

<p>Basically the LEDs can't produce enough current to charge the S&amp;H capacitor properly, and on top of that the LED doesn't act as a resistive load when not forward biased, so the input is basically floating and picking up noise.</p>

<p>The best cure is to add a voltage-follower buffer with incredibly high input impedance in front of the ADC input.</p>

<p>By high impedance I mean something measured in the 10s to 100s of TΩ. Something like the OPA355.</p>
