Servo motor control using potentiometer
Introduction
In this project, we will learn how to control a servo motor position using a potentiometer with the Arduino Uno.
A potentiometer acts as an analog input device that changes resistance when rotated. The Arduino reads this analog value (0–1023) and maps it to a servo angle (0°–180°). As you turn the knob, the servo shaft moves proportionally.
This is one of the most popular beginner projects in robotics and DIY electronics.
Key Components
-
Arduino UNO
-
Servo Motor (e.g., SG90)
-
10kΩ Potentiometer
-
Jumper Wires
-
Breadboard (optional)
Arduino UNO
Servo Motor (e.g., SG90)
10kΩ Potentiometer
Jumper Wires
Breadboard (optional)
Circuit Connections
Potentiometer:
-
One outer pin → 5V
-
Other outer pin → GND
-
Middle pin → A0
One outer pin → 5V
Other outer pin → GND
Middle pin → A0
Servo Motor:
-
Red wire → 5V
-
Brown/Black wire → GND
-
Orange/Yellow wire → Digital Pin 9
Red wire → 5V
Brown/Black wire → GND
Orange/Yellow wire → Digital Pin 9
If the servo jitters, use an external 5V power supply.
Working Principle
-
The potentiometer produces an analog voltage.
-
Arduino reads this value using analogRead().
-
The value (0–1023) is converted into an angle (0–180°) using map().
-
The angle is sent to the servo using the Servo library.
-
The servo rotates according to the knob position.
The potentiometer produces an analog voltage.
Arduino reads this value using analogRead().
The value (0–1023) is converted into an angle (0–180°) using map().
The angle is sent to the servo using the Servo library.
The servo rotates according to the knob position.
Arduino Code
#include <Servo.h>
Servo myServo;
int potPin = A0;
int servoPin = 9;
int potValue;
int angle;
void setup() {
myServo.attach(servoPin);
}
void loop() {
potValue = analogRead(potPin);
angle = map(potValue, 0, 1023, 0, 180);
myServo.write(angle);
delay(15);
}
Servo myServo;
int potPin = A0;
int servoPin = 9;
int potValue;
int angle;
void setup() {
myServo.attach(servoPin);
}
void loop() {
potValue = analogRead(potPin);
angle = map(potValue, 0, 1023, 0, 180);
myServo.write(angle);
delay(15);
}
Learning Outcomes
Students will understand:
-
Analog input reading
-
Mapping values in Arduino
-
Servo motor control
-
Manual robotic arm movement basics
Applications
-
Robotic arm control
-
Camera angle adjustment
-
Steering systems
-
DIY robotics projects
-
Automation prototypes
Robotic arm control
Camera angle adjustment
Steering systems
DIY robotics projects
Automation prototypes
Troubleshooting Tips
-
Ensure common GND between servo and Arduino.
-
Avoid powering high-torque servos directly from Arduino.
-
Check servo library installation if compilation fails.
Ensure common GND between servo and Arduino.
Avoid powering high-torque servos directly from Arduino.
Check servo library installation if compilation fails.
Code:
Try it in Tinker cad:
BEGINNER PROJECTS (Foundation Skills)
- Ultrasonic Distance Measurement
- Traffic Light Simulation with 7-Segment Display
- 7-Segment Display Counter
- Kids Piano Circuit (8-Key Version)
- 16×2 LCD Display with Text Output
- LCD I2C to Arduino UNO
- Temperature Measurement using Arduino UNO
- LDR Controlled Street Light
INTERMEDIATE PROJECTS (Build Your Skills)
- Servo Motor Control Using Potentiometer
- DC Motor Speed Control
- Temperature Controlled Fan
- PIR Based Theft Alert System
- LPG Gas Leakage Detection System
- Automatic Door Locking System
- Soil Moisture Based Automatic Watering System
- Simple Digital Clock using Arduino UNO
- Automatic Voting Machine (EVM)
- Joystick Control using Arduino Uno
- RGB Lamp Control using Arduino Uno
ADVANCED PROJECTS (Master Level)
- Home Automation Using Arduino UNO
- Bluetooth RC Car using Arduino Uno
- Obstacle Avoiding Robot
- Line Follower Robot
- Radar System Using Arduino UNO
- Automatic Parking System
- Bi-Directional People Counter using Arduino Uno
- Automatic Plant Watering System
- NeoPixel LED Ring Control using Arduino Uno
- Smart Gloves for Bedridden People
ROBOTICS & MOTION PROJECTS
- RC Car Using L293D Motor Driver
- Robot Arm and Leg Control Using Servo
- Smart Irrigation System using Arduino Uno

Comments
Post a Comment