In this DIY motor control with Arduino and TIP122 tutorial, we will be discussing how to use the TIP122 transistor to control a DC motor with an Arduino.We'll go over the basics of transistor operation, wiring diagrams, and code example and and video demonstration to help you get started with your own motor control project. Whether you're building a robot or automating a machine, this tutorial will give you the knowledge you need to control DC motors with precision and ease.
TIP122 transistor its features
TIP122 transistor
First let us briefly explain what TIP122 transistor is and its features. The TIP122 is a NPN Darlington transistor commonly used in power switching applications such as DC motor control, lamp dimming, and other load-driving applications. It can handle high current and voltage, making it suitable for use in power amplification circuits. It is also commonly used as a switch to drive loads such as relays and solenoids.
Features of TIP122
The features of TIP122 are as follows:
- High current capability: It can handle up to 5 A of collector current.
- High voltage capability: It can handle up to 100V of collector-emitter voltage.
- High current gain: The current gain of the TIP122 is typically 1000, which means that a small base current can control a large collector current.
- High power dissipation: It can handle up to 625mW of power dissipation.
- Epoxy-Molded Package: It is available in a robust epoxy-molded package which provides protection against environmental hazards such as moisture, dust and vibration.
- Complementary PNP device: The TIP127 is the complementary PNP device for the TIP122.
- Widely available: TIP122 is a widely used transistor and is available from many manufacturers.
Arduino, TIP122, Motor Circuit Diagram and Operation
The basic circuit diagram for controlling
a DC motor with an Arduino and TIP122 transistor is shown below.
The first step in setting up the circuit is to connect the Arduino to the TIP122 transistor. Connect the base of the TIP122 to one of the digital pins of the Arduino. Next, connect the collector of the TIP122 to the positive terminal of the DC motor and the emitter to the negative terminal of the DC motor. Note that the TIP122 transistor can handle high current and voltage, so be careful when working with high-power motors. Also remember to use a suitable power supply to provide the necessary voltage and current for the motor.
Arduino Program for Controlling DC Motors with Arduino and TIP122 Transistor
Now that the circuit is set up, we can begin programming the Arduino. We will be using the Arduino IDE to write the code for this tutorial. In the setup() function, we will define the digital pin that we are using to control the TIP122 as an output. In the loop() function, we will use the digitalWrite() function to send a digital signal to the base of the TIP122, which in turn controls the flow of current to the DC motor.
const int pot = 0;
const int mot = 10;
void setup () {
pinMode(pot, INPUT);
pinMode(mot, OUTPUT);
}
void loop() {
int p = analogRead(pot);
p = map(p, 0, 1023, 0, 255);
analogWrite(mot, p);
}
The code uses a potentiometer to control the PWM duty cycle which is used to control the DC motor. The potentiometer value is read, mapped to a new range
and then written to the PWM pin 10 to control TIP122 switch. It sets up two constants, pot and mot, which are assigned the values 0 and 10, respectively. These constants are used to represent the analog pin number of a potentiometer and the PWM pin number on the Arduino board.
The setup() function is called once when the Arduino board is powered on or reset. It sets the mode of the pot pin as INPUT, and the mode of the pin as OUTPUT.
The loop() function is called repeatedly after the setup() function has been called. Inside the loop() function, the code reads the analog value of the potentiometer using the analogRead() function and assigns it to the variable p. Then it maps this value from a range of 0-1023 to a range of 0-255 using the map() function and assigns the result to p. The analogWrite() function is used to write the value of p to the mot pin, which will set the PWM duty cycle.
This DC motor control code with PWM is a very simple one. Using analogwrite() function, the frequency is 500KHz but one can also control the frequency of the PWM signal. Also the PWM mode used by analogWrite() function is Arduino Fast PWM. But there is also another PWM mode which is Phase Correct PWM mode. If you are interested in learning more about frequency control the PWM mode see the tutorial ATmega328p Timer Programming Examples.
Video demonstration
The following video demonstrates how the motor control using Arduino and TIP122 transistor works.
Summary
In
conclusion, PWM motor control with Arduino and TIP122 transistor is a
simple and effective way to add motor control to your
projects. The TIP122 transistor is a versatile device that can handle
high current and voltage, making it suitable for a wide range of
applications. This tutorial should give you a good starting point for
controlling a DC motor with an Arduino and TIP122 transistor in your
next Arduino PWM controlled motor Control Projects. Instead of using
darlington transistor like TIP122, for smaller DC motor, we can also use
simple 2N2222A or BC547 general purpose transistor as illustrated in DC motor control with Arduino, Transistor, Diode. If you are interested in driving high-power motors with Arduino, the alternative to the TIP122 transistor is IRF540N E-MOSFET transistor which is demonstrated in .

