How to Make a Joystick Controlled Robotic Arm Using an Arduino Nano Board

How to Make a Joystick Controlled Robotic Arm Using an Arduino Nano Board

Hello and welcome back. In this project, we will learn how to make a joystick-controlled robotic arm using an Arduino Nano board. For this project, I used two joystick modules and a 4DOF robotic arm. Using the joystick modules, we can easily control the movement of the robotic arm in different directions. This project is very interesting and fun to build, and anyone can make it at home.

I also designed a custom PCB using JLCPCB. The PCB helps to reduce wiring connections and gives the project a clean, professional look. In this video, I will show you the complete step-by-step process, including the circuit connection, PCB, Arduino programming, and testing of the robotic arm. If you want to make an automatic control robotic arm, please use this link.

Ok, let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Second, let’s go step by step and place the order for the PCBs.

  • Click the “Instant Quote” button and upload the Gerber file, which you can download from the link below.
  • Gerber file – Download
  • For this project, I ordered five Green PCBs. Next, select the build time and shipping method. Finally, click “Save to Cart” and complete the payment.

Step 3

Thirdly, unbox your PCB package.

Step 4

Next, solder the female headers, male headers, and the DC power jack onto the PCB.

Step 5

Now, connect the Arduino Nano board and the joystick modules to the PCB. Then, attach the hexagonal copper spacers to the joystick modules for better stability. However, this step is optional, and you can skip it if you prefer.

Step 6

Next, assemble the robotic arm. The assembly process depends on your specific robotic arm model.

Step 7

Now, connect the servo motors to the PCB. After that, connect the Arduino Nano board to your computer and open the Arduino IDE. Then, copy and paste the following program into the IDE.

#include <Servo.h>

// Servo pins
#define servo1Pin 3
#define servo2Pin 5
#define servo3Pin 6
#define servo4Pin 9

// Joystick pins
#define joy1VRX A0
#define joy1VRY A1

#define joy2VRX A2
#define joy2VRY A3

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

// Start positions
int pos1 = 90;
int pos2 = 90;
int pos3 = 90;
int pos4 = 90;

// Speed
int speedValue = 1;

// Dead zone
int deadZone = 100;

void setup() {

  servo1.attach(servo1Pin);
  servo2.attach(servo2Pin);
  servo3.attach(servo3Pin);
  servo4.attach(servo4Pin);

  servo1.write(pos1);
  servo2.write(pos2);
  servo3.write(pos3);
  servo4.write(pos4);

  Serial.begin(9600);
}

void loop() {

  int joy1X = analogRead(joy1VRX);
  int joy1Y = analogRead(joy1VRY);

  int joy2X = analogRead(joy2VRX);
  int joy2Y = analogRead(joy2VRY);

  // ===== Servo 1 =====
  if (joy1X > 512 + deadZone) {
    pos1 += speedValue;
  }
  else if (joy1X < 512 - deadZone) {
    pos1 -= speedValue;
  }

  // ===== Servo 2 =====
  if (joy1Y > 512 + deadZone) {
    pos2 += speedValue;
  }
  else if (joy1Y < 512 - deadZone) {
    pos2 -= speedValue;
  }

  // ===== Servo 3 =====
  if (joy2X > 512 + deadZone) {
    pos3 += speedValue;
  }
  else if (joy2X < 512 - deadZone) {
    pos3 -= speedValue;
  }

  // ===== Servo 4 =====
  if (joy2Y > 512 + deadZone) {
    pos4 += speedValue;
  }
  else if (joy2Y < 512 - deadZone) {
    pos4 -= speedValue;
  }

  // Limit angles
  pos1 = constrain(pos1, 0, 180);
  pos2 = constrain(pos2, 0, 180);
  pos3 = constrain(pos3, 0, 180);
  pos4 = constrain(pos4, 0, 180);

  // Move servos
  servo1.write(pos1);
  servo2.write(pos2);
  servo3.write(pos3);
  servo4.write(pos4);

  delay(15);
}
  • Next, select the correct board and port in the Arduino IDE. After that, click the upload button to upload the code.

Step 8

Finally, remove the USB cable and power the system using an external 5V power supply. Now you can control the robotic arm using the joystick modules. The full video guide is provided below. We hope to see you in the next project.

How to Make a Joystick Controlled Robotic Arm Using an Arduino Nano Board

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *