This seems to be much of a beginners question,'but I couldn't find an answer..
Is there a maximum cable length when connecting a pushbutton for digitalread to work?
Thanks for any answers!
I think not really.
If unshielded, i think you can get a lot of HF-Input from enviroment. I would say: some handfull of meters wouldn't be a problem if using internal pullups.
If it's a shielded cable, i think it can be longer than you can afford to buy
![]()
(But i am not a pro...)
The best way to deal with long runs to switches is to lower the circuit impedance using a fairly low value external pull down resistor, say 500 ohms. Connect one side of the switch to the resistor, the other side of the switch connects to +5vdc. Also a .1ufd cap across the +5vdc and ground leaving the board to the switch will help knock down any EMI pick-up. You could probably run a hundred feet or more this way. That plus using a little denouncing delay on the input in your software should make it a pretty trouble free input signal.
Lefty
Twist the wires together, then any noise induced into the wiring is "common-mode" and in effect self cancels at the input terminals. Also fit a low value capacitor across the input terminals where the wires connect to the circuit board (somewhere around 0.01 microfarad or less), this will dampen any remaining noise. If the capacitor is too large then short presses of your switch may not be "seen" by the input circuit and the capacitors self inductance may not dampen noise sufficiently.
jack