Go Down

Topic: analogRead (Read 954 times) previous topic - next topic

cnash44

Nov 07, 2010, 10:19 pm Last Edit: Nov 07, 2010, 10:27 pm by cnash44 Reason: 1
Hello,

In an arduino mega analog pins are consistently displaying value with no hardware connected.

Test code is below, with serial monitor results.
 All pins have this behavior of reading values ~300 without input.

 I am expecting zero, any hints?
 Is something broken?

Thanks, cnash.

/*TESTCODE*/
const int Pin1 = 3;    
int ANALOG_PRESS_LEVEL = 0;

void setup() {
 Serial.begin(2400);  
 Serial.print("ALIVE_#");  
}

void loop(){
   ANALOG_PRESS_LEVEL = analogRead(Pin1);
   Serial.print(ANALOG_PRESS_LEVEL,DEC);
   Serial.print(", ");
   delay(1000);
}

/*OUTPUT*/
ALIVE_#390, 335, 329, 327, 325, 324, 324, 324, 323, 323, 323, 324,

robtillaart


As the pins are not connected to 0V or 5V the are floating just in between. Connecting a resistor between pin and GND helps.

Please read this tutorial that explains all http://arduino.cc/en/Tutorial/DigitalPins
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

cnash44

Thank you. My mistake. Corrected many months ago with the information referenced. Porting proof of concept to prototype introduced pull-down-resistor wiring error(trying to combine them). This indeed was the solution.

Best Regards,
Nash

Go Up