You hooked everything up, coding things. Then spent hours, if not days, looking over all your wiring and code... and can't find anything wrong. You searched the internet and only found vague references in old arduino forums... but the issue wasn't you. DC Motors create harmful interference can disrupt Arduinos, sensors, and other electronics. But here's how to stop it.
TLDR: Attach a 0.1uF (100nF) CERAMIC (electrolytic capacitors may be DANGEROUS) capacitor between both terminals of your DC motor. For optimal harmful noise reduction, soldier an additional 0.047uF (47nF) capacitor between each terminal and the motor casing.
DC Motors produce harmful electromagnetic (EM) interference that can cause all kinds of crazy things to happen (symptoms that can easily be confused with bad code!). I've had my 8V motors cause my micro servos to twitch out randomly, interfere with my IR receiver, confused my IR receiver data, and even reset my arduino. If you're having issues and your code seems fine, you're going to need up to three ceramic capacitors per motor.
By attaching a 0.1uF (100nF) ceramic capacitor between the position and negative terminals of your motor, you help absorb motor of the EMF that would travel thru its connected wires and into surrounding systems. This may not be enough, however, especially in higher voltage motor applications. Attaching an ADDITIONAL 0.047uF between each terminal and the motor casing will effectively turn your motor casing into an EMF shield, should have electrical silence from there on out. If you've done all that and still have issues, double check your code and triple check your solder. If you're me, and I am, then you suck at soldering and its going to crack and come loose 90% of the time after you spend an hour reconstructing your project... so yeah. Don't be me.
コメント