DC Motor Speed Control Using Arduino Nano Deshbot and Potentiometer
by devkrishnavhora in Circuits > Arduino
138 Views, 0 Favorites, 0 Comments
DC Motor Speed Control Using Arduino Nano Deshbot and Potentiometer
In this project, we control the speed of a 12V DC motor using an Arduino Nano, a DESHBOT Shield with L293D motor driver, and a potentiometer.
The potentiometer allows us to control the motor speed smoothly. By rotating the potentiometer, the PWM value sent to the motor driver changes, which changes the speed of the motor.
Supplies
Arduino Nano
DESHBOT Shield
L293D motor driver
12V DC motor
10K potentiometer
12V motor power supply
Jumper wires
Connections
Potentiometer
- Middle pin → A0
- One outer pin → 5V
- Other outer pin → GND
Motor
- Motor connection → D8 and D9
- D8 is used as the LOW/GND side
- D9 is used for PWM speed control
Working
The Arduino Nano reads the potentiometer using its A0 analog input.
The analog input gives a value between:
0 → 1023
The Arduino converts this value into a PWM value between:
0 → 255
This PWM signal is applied to the motor driver. As the potentiometer is rotated, the PWM value changes, allowing the motor speed to be controlled.
Control
Potentiometer minimum → Motor stopped/very slow
Potentiometer middle → Medium speed
Potentiometer maximum → Full speed
Code Explanation
Sure — here is the step-by-step explanation of the potentiometer direction + speed code.
1. Define the pins
- Potentiometer is connected to A1.
- Motor driver uses D8 and D9.
- A1 reads the potentiometer position.
2. Set the motor pins
Here we tell the Nano that D8 and D9 are outputs.
Both pins start LOW, so the motor is stopped.
3. Read the potentiometer
The Nano reads A1.
The value is:
4. Center position = STOP
When the potentiometer is around the center, both motor pins are LOW.
So the motor stops.
The range 480–543 is called the dead zone. It prevents tiny potentiometer fluctuations from making the motor move.
5. Potentiometer left = motor left
When you turn the potentiometer to the left:
- Near center → slow
- Further left → faster
- Fully left → maximum speed
map() converts the potentiometer position into a PWM value from 0 to 255.
6. Potentiometer right = motor right
When you turn the potentiometer to the right:
- Near center → slow
- Further right → faster
- Fully right → maximum speed
Now D9 gets PWM while D8 stays LOW, making the motor run in the opposite direction.
7. Final behavior
So the A1 potentiometer works like a joystick: left = motor left, center = stop, right = motor right, with speed increasing the farther you move from center.
Downloads
Conclusion
This project demonstrates how an Arduino Nano, potentiometer, and L293D motor driver can be used to control both the direction and speed of a DC motor. The potentiometer acts like a joystick: when turned to the left, the motor moves left; when turned to the right, the motor moves right; and when kept in the center, the motor stops. The farther the potentiometer is turned from the center, the faster the motor runs. This project helps in understanding analog input, PWM, motor control, and direction control using Arduino.