I have an Arduino connected to some stepper motors (with A4988 drivers mainly) and a push button switch (first figure below). Occasionally when I touch the case of a stepper motor, I get a spurious reading on the digital input for the switch. The motors need not be moving during this test. More odd, it’s likely to happen when I touch the stepper motor with a piece of metal rather than with my hand, and if I stand up rather than sit down (no, I am not grounded), so I assume it’s static electricity. I measure infinite resistance (or at least out of range – high megaohm) resistance between the motor case and each wire on two different NEMA 17 and NEMA 23 motors.
To better understand this, I even reproduced similar behavior on a second much simpler circuit (second figure below) containing just an Arduino and a switch, tested in a different room upstairs. When I touch ground (through a 33K resistor), sometimes I see that spurious reading on the switch’s digital input (and sometimes a thin spike on an oscilliscope). The spurious reading goes away if I disconnect the long (~4 foot long) wires to the switch or protect the digital input with a 1K resistor and 0.1uF capacitor as shown. Thinking that may be the solution, I tried adding similar protection to the switch in my first circuit or even just disconnecting the switch wires entirely, but the behavior still remains in the first circuit…
I’m using a 12VDC Pololu wall mount adapter to power these through the Arduino Vin. I tried even grounding the stepper motor case to the ground from this power supply, but that doesn’t help. I have a few > 100 uF capacitors and common ground on the A4988’s power as required, plus 0.1uF on both Vin and 5V.
What might I be missing?