analogRead

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,

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

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