Skip to the content.

3 Joint Robotic Arm

My BSE project was a 3 joint robotic arm. It has a claw and 3 joints to move in 3 axes and pick things up. It moves using servos. It can be controlled with a controller as well. All of these components are wired into the nanoshield, which is connected to the Arduino Nano. This is the core of the project and tells everything what to do.

Engineer School Area of Interest Grade
Sohum B Wissahickon Middle School Mechanical Engineering Rising 8th Grader

Headstone Image

Final Milestone

For my final milestone, I decided to change my modification. I was originally going to add Bluetooth to the robot, but due to some issues with the parts, I decided to change that. I ended up going with an LED modification. Whenever I move the left stick up, the yellow LED turns on. When I move the left stick to the right, the red LED turns on. And finally, whenever I move the right stick up, the blue LED turns on. I simply turn them the opposite direction to turn them off. My biggest triumph was defintely getting the code to work somewhat now, I mostly have control over the robot as compared to before when I didn’t. Also, adding the right finger without breaking it was a major success. I learned about C++ and Arduinos a lot, and I know some basic things. I hope to learn a lot more about mechanical engineering in the future in high school and college.

Second Milestone

My second milestone was to build the project in it’s entirety as well as coding it. I have achieved this goal, but not without some tribulations. My code does not really work at all, and it tends to go in random directions. This is definitely a challenge I am still working on solving. At this stage, the robot works via a controller (it doesn’t work half the time because of the code). It is all wired in and the physical structure is built. In the future, I will work on fixing the code as well as adding a modification, which I plan to be Bluetooth.

First Milestone

My first milestone was to build up a good amount of the base robot. I feel I achieved this goal as I have built roughly 3/4s of it. It works with servos connected to it acting as it joints. It rotates to move the arm. Some of my surprises were definitely how fragile the parts were. My biggest challenge was definitely breaking parts. I broke the right finger twice! For my next milestone, I hope to achieve the goal of coding and completely building my baseline project.

Schematics

Here are my schematics for the project. Headstone Image Headstone Image Headstone Image

Code

Here’s my code for the project:

/*
 * This code applies to cokoino mechanical arm
 * Through this link you can download the source code:
 * https://github.com/Cokoino/CKK0006
 * Company web site:
 * http://cokoino.com/
 *                                     ________
 *                         ----|servo4| 
 *                        |            --------
 *                    |servo3|   
 *                        |
 *                        |
 *                    |servo2|
 *                        |
 *                        |
 *                  ___________
 *                  |  servo1 |
 *         ____________________
 *         ____________________
 * Fanctions:
 * arm.servo1.read();   //read the servo of angle
 * arm.servo2.read();
 * arm.servo3.read();
 * arm.servo4.read();
 * 
 * arm.servo1.write(0);   //servo run
 * arm.servo2.write(0);
 * arm.servo3.write(0);
 * arm.servo4.write(0);
 * 
 * arm.left(speed);    //perform the action 
 * arm.right(speed);
 * arm.up(speed);
 * arm.down(speed);
 * arm.open(speed);
 * arm.close(speed);
 * 
 * arm.captureAction();    //capture the current action,return pointer array
 * arm.do_action(int *p,int speed);  //P is a pointer to the array
 * 
 * arm.JoyStickL.read_x(); //Returns joystick numerical
 * arm.JoyStickL.read_y();
 * arm.JoyStickR.read_x();
 * arm.JoyStickR.read_y();
 */
#include "src/CokoinoArm.h"
#define buzzerPin 9

CokoinoArm arm;
int xL,yL,xR,yR;

const int act_max=170;    //Default 10 action,4 the Angle of servo
int act[act_max][4];    //Only can change the number of action
int num=0,num_do=0;
///////////////////////////////////////////////////////////////
void turnUD(void){
  if(xL!=512){
    if(0<=xL && xL<=100){arm.up(10);digitalWrite(8,HIGH);return;}
    if(900<xL && xL<=1024){arm.down(10);digitalWrite(8,LOW);return;} 
    if(100<xL && xL<=200){arm.up(20);digitalWrite(8,HIGH);return;}
    if(800<xL && xL<=900){arm.down(20);digitalWrite(8,LOW);return;}
    if(200<xL && xL<=300){arm.up(25);digitalWrite(8,HIGH);return;}
    if(700<xL && xL<=800){arm.down(25);digitalWrite(8,LOW);return;}
    if(300<xL && xL<=400){arm.up(30);digitalWrite(8,HIGH);return;}
    if(600<xL && xL<=700){arm.down(30);digitalWrite(8,LOW);return;}
    if(400<xL && xL<=480){arm.up(35);digitalWrite(8,HIGH);return;}
    if(540<xL && xL<=600){arm.down(35);digitalWrite(8,LOW);return;} 
    }
}
///////////////////////////////////////////////////////////////
void turnLR(void){
  Serial.println(yL);
  if(yL!=512){
    if(0<=yL && yL<=100){arm.right(0);digitalWrite(9,HIGH);return;}
    if(900<yL && yL<=1024){arm.left(0);digitalWrite(9,LOW);return;}  
    if(100<yL && yL<=200){arm.right(5);digitalWrite(9,HIGH);return;}
    if(800<yL && yL<=900){arm.left(5);digitalWrite(9,LOW);return;}
    if(200<yL && yL<=300){arm.right(10);digitalWrite(9,HIGH);return;}
    if(700<yL && yL<=800){arm.left(10);digitalWrite(9,LOW);return;}
    if(300<yL && yL<=400){arm.right(15);digitalWrite(9,HIGH);return;}
    if(600<yL && yL<=700){arm.left(15);digitalWrite(9,LOW);return;}
    if(400<yL && yL<=480){arm.right(20);digitalWrite(9,HIGH);return;}
    if(540<yL && yL<=600){arm.left(20);digitalWrite(9,LOW);return;}
  }
}
///////////////////////////////////////////////////////////////
void turnCO(void){
  if(xR!=504){
    if(0<=xR && xR<=100){arm.close(0);digitalWrite(10,HIGH);return;}
    if(900<xR && xR<=1024){arm.open(0);digitalWrite(10,LOW);return;} 
    if(100<xR && xR<=200){arm.close(5);digitalWrite(10,HIGH);return;}
    if(800<xR && xR<=900){arm.open(5);digitalWrite(10,LOW);return;}
    if(200<xR && xR<=300){arm.close(10);digitalWrite(10,HIGH);return;}
    if(700<xR && xR<=800){arm.open(10);digitalWrite(10,LOW);return;}
    if(300<xR && xR<=400){arm.close(15);digitalWrite(10,HIGH);return;}
    if(600<xR && xR<=700){arm.open(15);digitalWrite(10,LOW);return;}
    if(400<xR && xR<=480){arm.close(20);digitalWrite(10,HIGH);return;}
    if(540<xR && xR<=600){arm.open(20);digitalWrite(10,LOW);return;} 
    }
}
///////////////////////////////////////////////////////////////
void date_processing(int *x,int *y){
  if(abs(512-*x)>abs(512-*y))
    {*y = 512;}
  else
    {*x = 512;}
}
///////////////////////////////////////////////////////////////
void buzzer(int H,int L){
  while(yR<420){
    digitalWrite(buzzerPin,HIGH);
    delayMicroseconds(H);
    digitalWrite(buzzerPin,LOW);
    delayMicroseconds(L);
    yR = arm.JoyStickR.read_y();
    }
  while(yR>600){
    digitalWrite(buzzerPin,HIGH);
    delayMicroseconds(H);
    digitalWrite(buzzerPin,LOW);
    delayMicroseconds(L);
    yR = arm.JoyStickR.read_y();
    }
}
///////////////////////////////////////////////////////////////
void C_action(void){
  if(yR>800){
    int *p;
    p=arm.captureAction();
    for(char i=0;i<4;i++){
    act[num][i]=*p;
    p=p+1;     
    }
    num++;
    num_do=num;
    if(num>=act_max){
      num=0;
      buzzer(600,400);
      }
    while(yR>600){yR = arm.JoyStickR.read_y();}
    //Serial.println(act[0][0]);
  }
}
///////////////////////////////////////////////////////////////
void Do_action(void){
  if(yR<220){
    buzzer(200,300);
    for(int i=0;i<num_do;i++){
      arm.do_action(act[i],15);
      }
    num=0;
    while(yR<420){yR = arm.JoyStickR.read_y();}
    for(int i=0;i<2000;i++){
      digitalWrite(buzzerPin,HIGH);
      delayMicroseconds(200);
      digitalWrite(buzzerPin,LOW);
      delayMicroseconds(300);        
    }
  }
}
///////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600);
  //arm of servo motor connection pins
  arm.ServoAttach(4,5,6,7);
  arm.servo1.write(190);   //servo run
  arm.servo2.write(90);
  arm.servo3.write(122.5);
  arm.servo4.write(0);
  //arm of joy stick connection pins : xL,yL,xR,yR
  arm.JoyStickAttach(A0,A1,A2,A3);
  pinMode(buzzerPin,OUTPUT);
pinMode(8, OUTPUT);}
///////////////////////////////////////////////////////////////
void loop() {
  xL = arm.JoyStickL.read_x();
  yL = arm.JoyStickL.read_y();
  xR = arm.JoyStickR.read_x();
  yR = arm.JoyStickR.read_y();
  Serial.print("xL:");
  Serial.println(xL);
  Serial.println(xR);
  Serial.println(yL);
  Serial.println(yR);
  date_processing(&xL,&yL);
  date_processing(&xR,&yR);
  turnUD();
  turnLR();
  turnCO();
  C_action();
  Do_action();
}



Bill of Materials

Here’s what everthing I used costed. Keep in mind that I ordered the ESP32 to initially have a Bluetooth modification, but since I had some issues, I swtiched to the LED modification instead. (All parts for that were supplied by the electronics kit.)

Part Note Price Link
Robot Arm Kit It is used for building the robot $45 Link
Servo Shield It is used as a safer board to plug everything in $10.98 Link
Screwdriver Kit Multi-head screwdriver kit allowing me to screw in any screw regardless of size $5.94 Link
Electronics Kit Gave me things like LEDs and jumper cables to modify my project $14 Link
9V Barrel Jack Lets me wire in a 9V battery to the servo shield/nano shield $6 Link
Digital Multimeter Allows me to measure the electrical current in a circuit $11 Link
9V Batteries Provides power to all of the electrical components of the robot $12.37 Link
ESP32 in Arduino Nano Form Factor Enables Bluetooth and WiFi capabilities for my robot $20.90 Link

Other Resources/Examples

Here is the GitHub tutorial I used. It takes you step by step as well as providing all of the code and drivers.