Input pin always HIGH, except when grounded.

Everything's on the topic... The 8 pin of my Decimilia always read HIGH, except when it's connected to the ground. I believe this may be due to an overvoltage on this pin.

Do you think this is possible ?

How would you prevent this, when you use sensors which basically just closes a relay ? I think I might just add a 220ch937 resistor after the relay, which should just connect the +5V and the input pin.

Thanks.

Everything's on the topic... The 8 pin of my Decimilia always read HIGH, except when it's connected to the ground.

I'm not sure I understand the problem. If an input pin is floating, I could easily see it always reading high depending on the voltages on nearby pins. If you want a floating input pin to read as low by default, use a pull-down resistor. If you want the input to read as high by default, enable the internal pull-up. Or am I not understanding what you're asking?

  • Ben

I should have been more specific : On a default setup, with no pins assignation, nothing connected to nothing, this code:

#define P 8

int x;

void setup() {
  pinMode(P, INPUT); 
  Serial.begin(9600);
}

void loop() {
  x = digitalRead(P);
  if (x==HIGH) {
    Serial.println("high");   } 
  else {
    Serial.println("low");
  }
}

Returns "cold cold cold cold cold etc." for pins 7 or 9, and "high high high high high" for pin 8. So I'm wondering if the pin could have been damaged, because I've tried to read a sensor with it by just connecting it to +5V through a relay... witch I think is not a great idea

I don’t think you can make any kind of assessment of pin damage based on its input value while floating. This could be completely normal behavior that’s just the product of the internal structure of the mega168, or even the product of the circuit the mega168 is in. I’m pretty sure your pin is just fine. Now if you fail to read low when you have a pull-down on there, then you can say that the pin is damaged!

  • Ben

Ok, then I believe it must be fine... I'm probably just unaccustomed to the randomness of electronics ^_^