Interference from motors on PWM signal
Brushed DC motors are notorious for throwing out EMI (electro-magnetic interference). The PRIMARY solution is to use a good bypass capacitor (like a 0.1uF ceramic) right across the power pins on the motor. AS CLOSE as you can get to the brushes.

Sometimes, with larger motors, it takes additional filtering in the form of shunt capacitors and even pi-filter elements with series inductors...





These photos are from a good tutorial on reducing EMI:
http://www.stefanv.com/rcstuff/qf200005.html

Additional bypassing of both power and signal lines is also beneficial. Capacitors can cause sluggish response in sensors if you use too much. It doesn't take large capacitors to be effective in shunting away ("filtering out") EMI.

Shielding and grounding are a "gray art" at best. Halfway between engineering and applied magic.