Go Down

Topic: Wrong analog read (Read 592 times) previous topic - next topic

belimawr

I am using LM35 to measure ambient temperature. It is connected to A15 on my Arduino mega and it is working well when used alone.
To display the temperature I am using a LCD shield which 5 buttons connected to A0. When I press one button it changes the voltage on A0, so reading the value on A0 I know what button is pressed.

With the actual temperature the right value returned by analogRead(A15) is something between 36 and 38, but when I use analogRead(A0) on my code and the pin A0 is connected to +5V (no button pressed) the read in A15 grows to something between 70 and 75...
But when I press any button (and the input on A0 is changed to something less than +5V) I get the right read on A15.

I've tried to use an delay of 1 second between those 2 reads, but it did not worked....

What could be wrong? Is it a bug, or am I doing something wrong?



Grumpy_Mike

Quote
I've tried to use an delay of 1 second between those 2 reads, but it did not worked....

Delaying between two reads of a different channel will do nothing for anything.
I am not sure what your setup is, a schematic would be good but if it is an impedance problem then read one channel, (optional delay) read it again and use the second value. Repeat for the other channel.

belimawr

I will try it, and if it do not work I will post here a schematic and my code

Go Up