My friend and I are repurposing an old rc car for a project. When we connect the dc motors to 5V and ground, the motors spin. However, when we power the motors from 5v and ground it in the digital output pin set to LOW, nothing happens. The identical circuit works in tinkercad. We are using a nano, but have tried an uno and mega as well.
-
you possibly destroyed the arduino output pin– jsotolaJul 4, 2020 at 4:16
-
An output pin can't handle that sort of current. I would suggest you do some reading on Ardunio and motors. If you google as much you'll be hit right off the bat with the idea of a motor driver since the pins can't drive motors by themselves. You've probably damaged your Arduino now.– Delta_GJul 4, 2020 at 4:17
-
The pin still works with leds and a small dc motor– Nicholas CarpenedoJul 4, 2020 at 4:24
-
2there is a lot of info about driving motors on this site– jsotolaJul 4, 2020 at 4:29
-
You shouldn't try to source or sink more than 20 mA from an Arduino pin. The absolute max is 40 mA, but 20 is the recommended limit. Also you should never hook an inductive load directly to an Arduino pin. When you disconnect an inductor from power, there is a large reverse rush of current as the magnetic field collapses. This is known as back-EMF, and even if you don't exceed the current limits of a pin, the back-EMF may fry the pin, or the entire board.– Duncan CJul 4, 2020 at 18:45
1 Answer
Never directly connect a motor to an Arduino IO pin
You will destroy the Arduino.
An Arduino cannot source (or sink in your case) enough current to drive a motor, and if the motor did manage to turn the huge amounts of EMI it generates would literally blast holes in the silicon inside the chip.
You must use a motor driver of some form. If you only want one direction that driver can be a single NPN Bipolar transistor or N-channel MOSFET. If you need it to change direction then an H-bridge is what you want.
-
-
To the OP: If you do end up powering your motors with transistors, make sure to add a "flyback diode" to protect the transistor from back EMF. (This is a suitably rated diode wired backwards across the motor terminals. They're needed for any inductive load, not just motors.)– Duncan CJul 4, 2020 at 18:48
-
Use that diode for the relay, too. As it is an inductive load, it will generate flyback spikes when switched off. Jul 4, 2020 at 19:13
-
Good point on the relay. I assumed the OP was using a "digital relay module" which has a transistor, diode, and usually an optic-isolator built into it.– Duncan CJul 4, 2020 at 19:32