Driving LEDs affects analogRead value

Hello all,

I have a simple circuit, that is running into a frustrating problem. I attached the circuit schematic. I am driving a heater (which i have substituted for a LED at the moment) while monitoring 2 analog inputs and 2 digital inputs.
The digital inputs are SPDT switches, one of which is also wired to an LED to monitor the switch state.
The analog inputs are reading the voltage across a voltage divider and a temp sensing chip.
I am also monitoring the voltage output from the temp sensing chip with a volt meter.
I am observing my analongRead values change depending on whether or not my circuit is driving the LEDs. For example, with Both switches to ground and digital13 LOW, I will read 2 values for A0 and A5. When i turn on both switches, which lights up both LEDs, the values i read for A0 and A5 will increase, despite the voltage remaining the same (confirmed using the voltmeter).
If I physically remove the LEDs without changing anything else, the values i read for A0 and A5 will return to the initial/correct state.
Has anyone noticed anything like this? Why does driving an LED affect my analogRead value?

Thanks in advance,
Sami

Returned A/D value depends on two things.
Voltage on the analogue pin AND the reference voltage for the A/D (Aref).
If voltage on the pin goes up, values go up.
If Aref (the 5volt supply) goes down (the load), values go up.
Good for a ratiometric voltage divider (pot), but bad for the voltage output of an analogue temp sensor (LM35?).

Could change Aref to the internal 1.1volt Aref.
Good for the analogue temp sensor, but bad for the voltage divider.
Or try to switch between the two Aref voltages in code (cumbersome).

Best solution is to use a digital temp sensor, like the DS18B20.
Leo..

Hi Leo,

Thanks for the reply! It was definitely a reference issue. As the various LEDs came on and off, i could measure a change in the 5V output from the board.
I am controlling an oven up to ~350C, so the LM35 type devices won't work. I'm using a AD595 with a thermocouple and need the ADC to measure up to 4000mV.
That all said, i changed the reference to 'external', used a nice linear bench top power supply, and the measurements were fairly stable regardless of LED operation.
My last lingering question. After the reference change to external, I have the 5V external supply hooked up to the AREF of the chip (and GND). Shouldn't hurt to also connect the external 5V supply to the board's 5V? Maybe two voltage supplies in parallel is a bad idea?

Thanks again,
Sami

Connecting the Aref pin to a different 5volt supply could be dangerous.
Aref will fry if Arduino supply is lower than the Aref pin.

Could use the 3.3volt pin of the (unspecified) Arduino as reference
(connect Aref to the 3.3volt pin, and set Aref to EXTERNAL).
Then you only need to to lower the output of the AD595 a bit with a voltage divider (and compensate in code).
Control pot then ofcourse also needs to be powered from the 3.3volt pin.
Leo..