I need to read four analog voltage for a project and am using arduino mega 2560 R3.
Requirement is to have a reference voltage as close to 5v as possible. As I found that the default to be considerably less than 5v and also inconsistent and decided to use an external voltage on AREF pin.
So, connected AREF pin to a 4.98v source and made the ground reference common for arduino and the source.
In code, made a call to analogReference(EXTERNAL) in setup() and am reading values one after the other in loop(). Please see attachment
However, I find that the analog readings for all channels shows some random value like “111” or “176” continuously.
Have tried giving a delay after reading, reading the analog pin multiple times and averaging the readings, all with the same error.
Unable to understand, where I am going wrong. Any suggestions would help a great deal.
thanks in Advance
AnalogTest.ino (965 Bytes)