Arduino really slow


I have two Arduino Mega 2560's. They worked fine a few months ago. Now when I go to use them, I upload either of the following examples (from File > Examples > Digital > ...): Button Debounce

and expect to see LED on pin 13 go high when button is pressed. It does, but it takes about 2-3 seconds to "reset" each time. Meaning, LED goes on instantly but stays on when connection is removed, and doesn't go off for 2-3 seconds.

It's as if there is a "delay(2000)" or something in my code, but there is not.

What I've tried with no luck: * Use arduino-0023 instead of arduino-1.0 * Use different USB port on my computer * Use different computer * Don't use USB port for power (i.e. unplug it), and plug Arduino in to the wall instead * Remove the button, and just have a wire from 5V to the relevant pin (pin 2), that I manually connect and disconnect to trigger it * Use my other Arduino Mega 2560, which has the exact same problem

This is extremely bizarre, and I can't do anything with such slow response times. Any ideas? I just want the LED to go on instantly when button is pressed, and go off instantly when button is not pressed, which is what the example code should do, but there is a huge delay.


Floating pin?

What does that mean? How do I check for it? How do I fix the floating pin?


P.S. The relevant code is here, so you don't have to look it up. Where should I make the modifications? Thanks

=== const int buttonPin = 2; const int ledPin = 13; int buttonState = 0;

void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); }

void loop(){

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } }

How is the switch wired? What size pull-down have you got on the input pin? Any reason for not using the built-in pullups and inverting your logic?

Aha! I understand. You were right -- floating pin. In my rush to get it working I forgot that pin 2 has to also be connected to a resistor to ground.