Arduino Mega 2560 reading the same value in all analog inputs


i have arduino mega 2560, analog inputs (a0 a15) started reading same value time without connected. values of adc output in analog input around 350~400 (decimal)
if connect signal (for exemple, in normal conditions input around 1v, give around  200 (dec) in adc output, right?) but  sums 300 error value in output 200, resulting 500

the point is: it's reading same value  , sum value signal inputed



example code used:

 int sensorpin = a1; // or a0, a2, a3...  of them
int sensorvalue=0;

void setup() {
  serial.begin(9600);
 
}

void loop() {
  sensorvalue = analogread (sensorpin);
  serial.print ("sensor = ");
  serial.println (sensorvalue,dec);
  delay(300);
}

its analog inputs (a0 a15) started reading same value time without connected. 
there 1 sample/hold capacitor in input of a/d converter.  if there nothing connected analog input pin there nothing sink or source current , capacitor retain last voltage put on it.  your hardware acting 1 expect.
you can never rely on particular value when reading unconnected pin.  use pull-up or pull-down resistor if want pin read high/1023 or low/0 when nothing else connected.


Arduino Forum > Using Arduino > Installation & Troubleshooting > Arduino Mega 2560 reading the same value in all analog inputs


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'