1. Introduction
Controlling the speed of a DC motor is an important requirement in robotics, automation, and embedded systems. In this project, Arduino Uno is used to generate a PWM (Pulse Width Modulation) signal, and the L293D motor driver IC is used to drive the DC motor safely. The motor speed is controlled using a potentiometer.
2. Components Required
-
Arduino Uno
-
L293D Motor Driver IC
-
DC Motor
-
10kΩ Potentiometer
-
External Motor Power Supply (6V–12V)
-
Breadboard
-
Connecting Wires
3. Circuit and Connections
L293D to Arduino Uno
| L293D Pin | Function | Arduino Pin |
|---|---|---|
| Pin 1 | Enable 1 (ENA) | Pin 9 (PWM) |
| Pin 2 | Input 1 (IN1) | Pin 8 |
| Pin 7 | Input 2 (IN2) | Pin 7 |
| Pin 3 | Output 1 | Motor Terminal 1 |
| Pin 6 | Output 2 | Motor Terminal 2 |
| Pin 4,5,12,13 | Ground | Arduino GND |
| Pin 8 | Motor Supply | External Battery + |
| Pin 16 | Logic Supply | Arduino 5V |
Potentiometer Connections
-
Middle pin → Arduino A0
-
Other two pins → 5V and GND
4. Circuit Working
The Arduino reads the analog voltage from the potentiometer using pin A0.
This value ranges from 0 to 1023.
Arduino converts this value into a PWM signal between 0 and 255 using the map() function.
The PWM signal is applied to the Enable pin (Pin 1) of the L293D.
As the PWM duty cycle increases, the average voltage applied to the motor increases, which increases the motor speed.
The Input pins IN1 and IN2 decide the direction of rotation:
-
IN1 = HIGH and IN2 = LOW → Motor rotates forward
-
IN1 = LOW and IN2 = HIGH → Motor rotates reverse
In this project, the motor runs only in the forward direction and its speed is controlled using the potentiometer.
5. Arduino Code
// Pin Definitions
const int potPin = A0;
const int enablePin = 9;
const int motorPin1 = 8;
const int motorPin2 = 7;
void setup() {
pinMode(enablePin, OUTPUT);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
// Motor direction: Forward
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
}
void loop() {
int potValue = analogRead(potPin);
int motorSpeed = map(potValue, 0, 1023, 0, 255);
if (motorSpeed < 10) motorSpeed = 0; // Dead zone to stop motor
analogWrite(enablePin, motorSpeed);
}
6. Working Tips
-
Always use an external power supply for the motor. Do not power the motor from Arduino 5V.
-
Ensure that Arduino GND and motor supply GND are connected together (common ground).
-
Use a PWM pin (~) for the Enable pin of L293D.
-
Do not connect the motor directly to Arduino pins; always use a motor driver IC.
-
If the motor vibrates but does not rotate, increase the supply voltage slightly.
-
Keep the motor wires short to reduce electrical noise.
7. Applications
-
Robot wheel speed control
-
Conveyor belt control
-
Fan speed control
-
Water pump control
-
Automatic door systems
8. Conclusion
In this project, DC motor speed control was successfully implemented using Arduino Uno and the L293D motor driver IC. The speed of the motor was controlled by varying the PWM duty cycle using a potentiometer. This method is simple, reliable, and widely used in robotics and automation applications. By modifying the code, the same setup can be used to control direction and speed of multiple motors.