WiFi shield Pin 4 usage - stays "HIGH" after button push

Dear forum,
I have a question regarding the WiFi shield and the pin 4 which (hopefully) only is used, when I use the SD card library.
I have wired a button to the pin (with pulldown) and configured it as an input.
See this very trivial example:

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

void loop()
{
  Serial.println(digitalRead(4)); 
}

On a "naked" Arduino Uno R3, this works as expected. I get a lot of 0s and when I push the button, I get 1s. When I release the button, I get 0s again.

Now this exact same code on an Arduino Uno R3 with a WiFi shield on top acts weird:
First I get 0s, when I push the button I get 1s. And when I release the button, I keep getting 1s forever.

I have the same behavious when I set up and use the WiFi shield to actually connect to a network. I set up just the WiFi part. I do not use the sd library in my code.
The documentation says, that pin 4 is used for the sd library. Do I have to turn it off somehow, so that the pin acts as a normal I/O pin when I don't use it?
Since I have wired a LCD, I'm running out of pins, so it really would be great, if I could use pin 4.
My forum and google searches did not bring any hints.

Does anybody have an idea?
Greetings
Konk

SD_CS goes through a TXB0108 (8-bit bidirectional voltage-level translator with auto-direction sensing). I've had trouble with these in the past. Basically the signals can be latched, and thus it is possible (probable in fact from what you describe) that once you bring pin 4 high it latches. Then the weak pull-down is not enough to un-latch it. To un-latch it you have to drive it low.

Hi Nick,
thank you very much for your information. I suspected it to be a hardware problem. Driving the pin low by hand (in the code) will make my debouncing a little more complicated, since the pin can be down for long times. I might get me a Leonardo. The additional I/Os would be very useful for my project anyways.
Thanks again for the fast response

Look on the bright side. If it latches it won't bounce. :slight_smile:

Once you detect it pressed drive it low after 200 mS or so.