Robotic Arm Control
with 4 Servos & Potentiometers
Build a manually controlled robotic arm with 4 independent joints. Turn a knob, move a joint — exactly like a real robot manipulator.
What Are We Building?
This project simulates the basic movements of a robot arm and legs using Arduino UNO, 4 servo motors, and 4 potentiometers. Each servo represents a joint (shoulder, elbow, hip, knee) and each potentiometer acts as a manual control knob. Turn the knob — the joint moves. It's a hands-on introduction to robotic control systems.
map() function to scale values4 Potentiometers → 4 Joints
Each potentiometer directly controls one servo joint. Turn the knob, the joint moves proportionally — from 0° to 180°.
🦾 Shoulder
Controls the base rotation of the arm. Determines left-right reach direction.
💪 Elbow
Controls upper arm bend. Raises or lowers the forearm segment.
🕺 Hip
Controls leg/body rotation. Simulates forward-backward leg movement.
🦵 Knee
Controls lower leg bend. Simulates crouching or stepping motions.
What You Need
| # | Component | Qty | Role |
|---|---|---|---|
| 1 | Arduino UNO | ×1 | Reads all 4 potentiometers and commands all 4 servos |
| 2 | Servo Motor (SG90) | ×4 | Shoulder, Elbow, Hip, Knee joints |
| 3 | 10 kΩ Potentiometer | ×4 | Manual control knobs — one per joint |
| 4 | Breadboard | ×1 | Clean wiring layout for all components |
| 5 | Jumper Wires | ×~25 | All component connections |
| 6 | Power Supply | ×1 | Arduino 5V or external 5V/2A for 4 servos |
Control the Arm with Sliders
Drag each slider to simulate turning a potentiometer. Watch the robotic arm joints move in real time.
Interactive Robotic Arm — 4-Joint Controller
Wiring All 4 Pairs
📻 Potentiometers (all 4 share 5V and GND)
⚙️ Servo Motors
The Control Loop
The Arduino continuously reads all 4 potentiometers and updates all 4 servos — this loop runs approximately every 15 ms.
-
Turn Potentiometer Knob
The wiper pin outputs a voltage between 0 V (fully left) and 5 V (fully right).
-
Arduino Reads All 4 Analog Pins
analogRead(A0)throughanalogRead(A3)each return a value from 0 to 1023. -
map() Converts the Range
0–1023 is linearly scaled to 0°–180° using
map(val, 0, 1023, 0, 180). -
All 4 Servos Move Simultaneously
servo.write(angle)is called for each joint, moving it to the correct position. -
Loop Repeats Every 15 ms
The
delay(15)gives each servo time to physically reach its position before the next update.
🔄 The map() Function for All 4 Joints
// Same formula used for ALL 4 joints:
angle1 = map(analogRead(A0), 0, 1023, 0, 180); // Shoulder
angle2 = map(analogRead(A1), 0, 1023, 0, 180); // Elbow
angle3 = map(analogRead(A2), 0, 1023, 0, 180); // Hip
angle4 = map(analogRead(A3), 0, 1023, 0, 180); // Knee
The Program
The code follows the same pattern for all 4 joints — read, map, write. Clean, readable, and easily expandable.
#include <Servo.h> // ── Servo Objects ───────────────────────────── Servo servo1; // Shoulder Servo servo2; // Elbow Servo servo3; // Hip Servo servo4; // Knee // ── Potentiometer Pins ──────────────────────── int pot1 = A0; int pot2 = A1; int pot3 = A2; int pot4 = A3; // ── Angle Variables ─────────────────────────── int val1, val2, val3, val4; int angle1, angle2, angle3, angle4; void setup() { servo1.attach(3); // Shoulder → Pin 3 (PWM) servo2.attach(5); // Elbow → Pin 5 (PWM) servo3.attach(6); // Hip → Pin 6 (PWM) servo4.attach(9); // Knee → Pin 9 (PWM) } void loop() { // ── Read Potentiometers ─────────────────────── val1 = analogRead(pot1); // 0–1023 from Shoulder pot val2 = analogRead(pot2); // 0–1023 from Elbow pot val3 = analogRead(pot3); // 0–1023 from Hip pot val4 = analogRead(pot4); // 0–1023 from Knee pot // ── Map to Servo Angles (0°–180°) ───────────── angle1 = map(val1, 0, 1023, 0, 180); angle2 = map(val2, 0, 1023, 0, 180); angle3 = map(val3, 0, 1023, 0, 180); angle4 = map(val4, 0, 1023, 0, 180); // ── Move Servo Joints ───────────────────────── servo1.write(angle1); // Shoulder servo2.write(angle2); // Elbow servo3.write(angle3); // Hip servo4.write(angle4); // Knee delay(15); // Allow time for servos to reach position }
💡 Key patterns in this code
- Consistent structure — read, map, write is repeated identically for all 4 joints
- Servo objects — each servo needs its own
Servoobject (servo1, servo2…) - PWM pins only —
.attach()must use pins 3, 5, 6, 9, 10, or 11 on UNO - delay(15) — 15 ms minimum for a servo to settle at its commanded angle
Run the Full Simulation
All 4 servo-potentiometer pairs are pre-wired in Tinkercad. Start simulation and drag each potentiometer knob to control the robotic joints.
Open Robotic Arm Simulation
Pre-built circuit with 4 servos and 4 potentiometers. Click each pot dial and rotate it to control the corresponding joint.
🧪 Challenges to try
- Start simulation — rotate each potentiometer and watch its servo respond.
- Try moving all 4 knobs simultaneously to see complex arm poses.
- Change
map(..., 0, 180)tomap(..., 30, 150)to limit the shoulder's travel range. - Challenge: Add a 5th potentiometer and servo for a gripper/claw.
- Advanced: Store a sequence of positions and replay them automatically (teach & playback).
Quick Quiz
Click an option to check your answer instantly.
Q1. How many Servo objects are needed to control 4 servo motors?
Q2. Potentiometer 3 controls which joint?
Q3. Why must servos be attached to PWM pins (3, 5, 6, 9)?
Q4. If analogRead(A2) returns 768, what angle will Servo 3 (Hip) be at?
Where Is This Used?
🚀 Ready to level up?
- Add a 5th servo for a gripper to pick up objects
- Replace potentiometers with a joystick module (2-axis control with one hand)
- Add EEPROM memory to save arm positions and replay them
- Use inverse kinematics to control end-effector position instead of joint angles
- Add a Bluetooth module to control the arm from a smartphone app
Comments
Post a Comment