Skip to main content

Building a Simple Robot Arm with Servo Motor and Joystick

How to contruct a robotic arm?

A simple robotic arms is basically like human arm which consists of upper arm, lower arm and hand (gripper). There is a lot of online resources of laser cut files that you can use. After you have found one or design one, you can go to 3D Workshop to laser ut the hardware. In this toturial we will focus on how to control the servo motor (the joint of your robotic arm) with two potentiometers.


You can use more or less servo motors in your design based on how many joints you need.In this toturial we will use two servo motors, one for the rotation at the base and one for the angle of the upper arm.


  1. Servo: Power to 5V
  2. Servo: Ground to GND
  3. Servo: Signal to 6/10
  4. Potentiometer: Right pin to 5V
  5. Potentiometer: Left pin to GND
  6. Potentiometer: Middle pin to A0/A1


Getting started

This code is getting the servo motors to rotate based on the potentiometers' values.

#include <Servo.h>

#define potRotation      A0 
#define potAngle      A1 
#define servoRotation  10  
#define servoAngle  6 

// create servo object to control a servo 
Servo rotateServo;  
Servo angleServo; 

void setup() {
  Serial.begin(9600) ;

void loop() {
  // read analog potentiometer values
  int rotation = analogRead(potRotation);
  int angle = analogRead(potAngle);

  int rotationMapped = map(rotation, 0, 1023, 0, 180); // scale it to the servo's angle (0 to 180)
  int angleMapped = map(angle, 0, 1023, 0, 180); // scale it to the servo's angle (0 to 180)

  rotateServo.write(rotationMapped); // rotate servo motor 1
  angleServo.write(angleMapped); // rotate servo motor 2

  // print data to Serial Monitor on Arduino IDE
  Serial.print("potRotation: ");
  Serial.print(", potAngle:");
  Serial.print(" => Servo Motor Rotation: ");
  Serial.print("°, Angle:");