I'm building a CNC mill and am trying to set up an emergency kill switch. I have a pushbutton going to D2 and a routine watching it via attachInterrupt(). In case it's relevant, my board is a Duemilanove with a 328 upgraded to OptiBoot.
The pushbutton is connected to the Arduino via about 10" of one twisted pair from an old Cat5 cable. I first tried using the internal pullup but I was getting spurious interrupts whenever the Dremel spindle started or stopped.
Tonight I switched to a physical 10K resistor wired as a pulldown and changed the code to attachInterrupt(0, RISING). That seems to have eliminated 99% of the problems, but I'm still getting an occasional false positive from the switch when the steppers and Dremel are running.
Does anyone have a hardware fix for this? I think I can solve it with a counter inside the interrupt routine (e.g. the kill button must be pressed for 20ms) but learning new things is always good.
Thanks as always.