Pages: [1]   Go Down
Author Topic: Wrong analog read  (Read 567 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?


Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: