Hello,
I'm using the ADC on A1 and when using the default 5V as the reference this works fine. I'm trying to use the internal 1v reference but that does not seem to work.
analogReference(INTERNAL); // internal 1V ref
After setting the reference to Internal, I wait 10-20 ms to allow setting time but this has not helped.
Any suggestions?
int InPin = A1;
int sensorValue = 0;
sensorValue = analogRead(InPin); // this works over 0-5 volts perfectly.
// this portion does not
analogReference(INTERNAL); // internal 1V ref
delay(10); // 10ms delay for settling
sensorValue = analogRead(InPin);
After selecting (INTERNAL) I get 0 counts in sensorValue. The DC value of A1 input in this case is about 200 mV.
thanks
Have you tried doing two consecutive analog reads after issuing the reference change? I think the first read after a change of reference is always bad and just having a delay doesn't cure that 'feature'.
OK, found the problem. I found in the docs a mention that analogReference() just sets a global variable that is used when analogRead() is called so a delay is needed after a first read.
so the right sequence is this: