Arduino – Control a DC motor with TIP120, potentiometer and multiple power supplies

arduino Pot motor side

A quick circuit showing how to control the speed of a DC motor with a potentiometer with your Arduino board. Also shows how to use a TIP120 transistor to allow the Arduino control a larger power supply.

Transistors are 3 pin devices, which via the 3rd pin (Base) allow it to control the current passing through the other 2 pins (Collector and Emitter). So for this tutorial I am using the power from the Arduino Digital PWM pin 9 (+5V) to control the flow of current to a DC motor which uses an additional power supply with a much larger current than the Arduino board can supply or control. Of course like most electrical components each transistor is designed for a specfic operating range or current.

Below you can see TIP120 the pins and how they appear in a schematic:


1N4004-DiodeSo thats the transistor. Next up is the rectifier diode, I’m using this inbetween the power supply flowing from the motor. It acts like a one way valve to only allow the current to flow one way, so my circuit should be protected should the motor power supply cause a surge or if the motor draws too much current. The main thing to remember is that Diodes like LED’s have a correct orientation, shown to the left.

The other item is the potentiometer, which is basically a variable resistor. By turning it you control the flow of current by allowing more or less through. Potentiometers, like resistors have a resistance rating in Ohms and a power rating. For this I am using a pot with a 10K ohm rating.

Arduino TIP120 Circuit Components

1K Ohm resistor (Brown, Black, Red, Gold)
10k Potentiometer
TIP120 Transistor
1n4004 1A Diode
6V DC motor
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires
4x AA battery holder
4x AA batteries
Optional 9V DCpower supply or use the USB power for the Arduino

TIP120 Arduino DC Motor Control Circuit

Pretty simple, but remember that the GND connection must be shared between the Arduino and the additional power supply and I’m using a 1k Ohm resistor between Arduino pin 9 and the Base pin of the transistor.


TIP120 DC Motor Driver Sketch

[ad#Google Ad in content]

int potPin = 0;                           // Analog pin 0 connected to the potentiometer
int transistorPin = 9;                  // connected from digital pin 9 to the base of the transistor
int potValue = 0;                       // value returned from the potentiometer

void setup() {                          // set  the transistor pin as an output
  pinMode(transistorPin, OUTPUT);

void loop() {                           // read the potentiometer, convert it to between 0 - 255 for the value accepted by the digital pin.
  potValue = analogRead(potPin) / 4;    // potValue alters the supply from pin 9 which in turn controls the power running through the transistor
  analogWrite(9, potValue);

[ad#Google Ad in content]

I’m going to use the above and the work I’ve done with the Arduino and L293D chip so far to control the speed and direction to the motor with a potentiometer.


  • Hi, I found this tutorial very helpful for what I wanted ! Thanks !

  • Im living in Ireland and am finding it very difficult to get a Tip120. Would it be possible to use a Tip121 instead?

    • TIP121 should be fine if you look at the datasheets they’re basically identical. I’m using the TIP120 because its emitter pin uses no more than 5 Volts which is what you’re looking for with the Arduino – so you could find any part that has the same properties and it should be OK. You’ll see its collector pin can handle around 60 Volts (I think). If you have any issues I have a few spare TIP120’s 🙂

  • How to make it work for 2 12v DC motor?

  • Surely to make it go CW or CCW, you could add a DPDT switch between the wires that go “to motor” and the wires from the motor? Basically switch which way round the wires are connected..

    • Actually I guess this wouldn’t work so well on a robot who you aren’t interacting with!! But I just set it up and it worked fine with a simple switch 🙂 thanks a lot for your info

  • I was wondering if this set up would some how be modified to run 2 12v hobby motors that are being suspended on separate tracks to run in sinc with one another? Such as making two of the Arduino boards shown above and connecting it to a interface to time them speeds and distances.

  • there seems to be something wrong with the code

    I get this error
    “cant find anything named output”

    im new to all of this so I hope im not being stupid about this..



  • hahahaha. sorry for the haisty comment. I had procesing open in sted of arduino :Þ

    sry again …

  • Larry,

    With all due respect, your detail is just awesome! Two textbooks and 5 youtube videos and you were the only one who specified the direction of the stinkin diode.

    Thank you! Was going out of my mind!

    • thanks, nice to know it’s just not me who needs to know these things as well!

  • Hey, why do you scale the val by 4?

  • I have the same doubt as SS… why do you scale the val by 4?

    • Because the analog input is 10 bit, and the output is 8 bit.
      Analog in: 0-1023
      Analog out: 0-255

  • […] circuito foi baseado no tutorial do site:… Share this:TwitterFacebookGostar disso:GostoSeja o primeiro a gostar disso post.   Leave a […]

  • this is very helpful for me for my project… thanks

  • Sir. I need to use AC 230v Fan instead of 6V DC motor. So Can u help me how to do?
    My project is temperature controlled fan. Here, Speed of the fan divided into 3 stages.
    Plz Help me

You must be logged in to post a comment.