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:

So 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.
Shopping list
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 power supply (here) or use the USB power for the Arduino
The 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.
The sketch
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); }
After thoughts
I’m going to use the above and the work I’ve done with the L293D chip so far to control the speed and direction to the motor with a potentiometer.
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
- Control a DC motor with Arduino and L293D chip
- Controlling a Servo with Arduino
- Arduino + Processing: 3D Sensor Data Visualisation
- Arduino: Using a Sharp IR Sensor for Distance Calculation
- Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 2: Visualising the Data
- Arduino: Basic Persistance of Vision
- larryBot – versions 0.1 to 0.5 lessons learned
- Arduino: making a basic drum machine
- Arduino: (Very) Basic motion tracking with 2 PIR sensors
- Using Processing to Send Values to Arduino










Hi, I found this tutorial very helpful for what I wanted ! Thanks !
Glad it helped you out.