Is is possible to control a toy DC motor (5V) on an Arduino directly from the Analog (or Digital with PWM) pin without damaging the board? I know that DC motors are usually controlled via a transistor but I am thinking of controlling it this way. My Arduino code is:

    void setup() {
         pinMode(6, OUTPUT);
    void loop() {
         int val = Serial.parseInt();
         if( val >= 0 && val <= 1024) {

My schematic:

GND---------------------MOTOR--------------|<|-------D6 (PWM)

  • \$\begingroup\$ Welcome to EE.SE! You will get much better answers if you provide as much information as you can. How much current does the motor draw when it is running? How about when it is stalled? Also, your schematic is not really a schematic...can you clarify the symbol between the MOTOR and D6, and why you decided to include it? \$\endgroup\$ – Joe Hass Jan 1 '14 at 17:18

There are a number of problems with your approach - while simple, you will be facing a number of challenges.

  1. The maximum current output from your Arduino will probably be a maximum of around 40mA (http://arduino.cc/en/Main/ArduinoBoardUno). This is insufficient to drive a hobby motor. Most small project motors will draw 100 to 500 mA of current. I think you might be at risk of damaging your Arduino.

  2. Even if the motor could be run at a very low current (less than 40mA), motors are noisy - they use brushes and contacts that create electrical noise that can cause interference with the microcontroller. There are techniques for removing this noise, like using filter capacitors connected to ground and sometimes a diode across the motor (http://www.pololu.com/docs/0J15/9).

  3. Lastly, you would be limited to the voltage supplied by the microcontroller (in this case 5V DC). Many motors run at different voltages - such as 6V or 12V.

There are many good circuits describing how to run a motor using easy to find components if you do a quick search on Google!

| improve this answer | |

"It depends" :-)

If the motor in question has a stall current rating well below the current that can be safely drawn from an Arduino GPIO, then yes, such a DC motor could be driven directly from the GPIO pin.

A protection diode across the motor, preferably a fast Schottky diode, is strongly recommended to shunt the back EMF from the motor commutation, and save the Arduino pin from damage.


simulate this circuit – Schematic created using CircuitLab

Personally I would restrict such adventures to motors with a stall current rating of 20 mA or lower (for the classic Arduino boards). Some of the newer Arduino boards have a lower current rating per GPIO pin, so caveat emptor.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.