Analog Pins with mystery voltage in Mega 2560
arduino mega 2560 reads voltage in analog in pins while nothing connected. i noticed problem while working bugs out of photo-resistor/ir sensor project. finally wrote sketch read analog pins serial monitor , read out number starts shy of 400, on span of few seconds drop 300.
is defective board? am missing something? nothing plugged in except usb... code , serial monitor info provided below.
few seconds down line...
thanks input have!
is defective board? am missing something? nothing plugged in except usb... code , serial monitor info provided below.
quote
void setup(){
serial.begin(9600);
}
void loop(){
serial.println(analogread(1));
}
quote
2÷393
393
394
395
397
398
few seconds down line...
quote
286
286
287
286
286
287
286
thanks input have!
floating pins (aka unconnected pins) pick stray energy, creating voltage on them.
it sort of why following note on analogread() reference page:
"if analog input pin not connected anything, value returned analogread() fluctuate based on number of factors (e.g. values of other analog inputs, how close hand board, etc.)."
it sort of why following note on analogread() reference page:
"if analog input pin not connected anything, value returned analogread() fluctuate based on number of factors (e.g. values of other analog inputs, how close hand board, etc.)."
Arduino Forum > Using Arduino > Installation & Troubleshooting > Analog Pins with mystery voltage in Mega 2560
arduino
Comments
Post a Comment