Skip to main content

How to build a Simple Robot Arm with Servo Motor and Joystick

How to construct a robotic arm?

A simple robotic arm is basically like a human arm which consists of the upper arm, lower arm and hand (gripper). There are a lot of online resources for laser-cut files that you can use. After you have found one or designed one, you can go to the 3D Workshop to laser cut the hardware. In this tutorial, 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 tutorial, 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:");