Move two servos smoothly with a thumb joystick — the exact mechanism behind camera gimbals, robot heads and sensor turrets.
What you’ll build
The joystick is two potentiometers: X and Y. The Arduino Nano maps each axis to a servo angle, driving an SG90 pair arranged as a pan-tilt bracket. Push the stick and the mount follows in real time.
Components you’ll need
| Component | Qty | Price |
|---|---|---|
| Arduino Nano ATmega328P Compatible Board | 1 | ₹149 |
| Joystick Module | 1 | ₹39 |
| SG90 Micro Servo Motor 9G | 2 | ₹178 |
| 400 Point Breadboard | 1 | ₹299 |
| Jumper Wires MM | 1 | ₹299 |
| Total | ₹964 |
Step-by-step guide
- Wire the joystick: VCC to 5V, GND to GND, VRx to A0, VRy to A1.
- Connect the pan servo signal to D5 and the tilt servo signal to D6; power both from 5V and GND (use the breadboard rails).
- If the servos twitch, add a 100–1000µF capacitor across the servo power rails.
- Stack the servos into a pan-tilt bracket, or hot-glue the tilt servo onto the pan servo’s horn.
- Upload the sketch and steer with the stick — movement is smoothed so the mount doesn’t jerk.
The code
Mapping is direct: 0–1023 from each pot becomes 0–180 degrees, with a small smoothing filter for fluid motion.
#include <Servo.h>
Servo pan, tilt;
float px=90, py=90;
void setup(){ pan.attach(5); tilt.attach(6); }
void loop(){
int tx = map(analogRead(A0), 0, 1023, 0, 180);
int ty = map(analogRead(A1), 0, 1023, 0, 180);
px += (tx - px) * 0.15; // smoothing
py += (ty - py) * 0.15;
pan.write(px); tilt.write(py);
delay(15);
}Build this project
Add all 5 required components to your cart in one click — total ₹964.
Add all components to cart