3D Printed Arduino Based Robotic Arm

6,400

108

11

Introduction: 3D Printed Arduino Based Robotic Arm

About: I am a High School Junior who spends his free time 3D printing, 3D modeling, and designing robots.

Inspiration for this project:

One year, I received a robotic arm kit for Christmas made out of acrylic parts and controlled with an Arduino. I put it together and uploaded the code to the Arduino board, only to be disappointed with its performance. I spend a good deal of time troubleshooting it, but I didn't have any success. Finally, I put the kit aside and pursued other projects.

A few months ago, I came back to the robotic arm kit and figured out what the issues were. If I did my research correctly, most servo motors draw about an amp of current. I think that the power supply provided in this kit did not provide enough current to power all of the servo motors in the robotic arm, resulting in the motors having a "jerky" effect (for lack of a better term).

Before I came to this conclusion, I realized I did not like the acrylic parts as building materials. They were not structurally advantageous, and they were noisy (the friction between them made the parts creek). At this point, I decided to just design and build my own robotic arm with 3D printed parts.

This project will walk you through:

  1. The design process
  2. How to build the arm
  3. Programming the arm

Supplies

Here are the parts I used for this project.

Hardware (screws, nuts, etc.):

  • m2 screws (assortment of lengths)
  • m2 nuts
  • m3 screws (assortment of lengths)
  • m3 nuts
  • m4 screws (assortment of lengths)
  • m4 nuts
  • m2 hex standoffs (must be hex):
    • m2x10
  • 22 gauge solid core wire (stripped)

Electrical (servos, boards, etc.):

  • Arduino Mega
  • smraza S52 micro metal gear servo (x2)
  • smraza SG90 micro servo motor (x1)
  • Tower Pro SG-5010 double ball bearing servo (x1)
  • Tower Pro MG-906R high torque servo (x2)
  • General electrical components:
    • wire, pin headers, etc.

Tools (access to these):

  • Soldering Iron
  • 3D printer
  • Computer
  • Generic tools (hammer, screw driver, etc.)

Note: The 3D printed parts are designed around these specific items and brands.

Step 1: Video Demonstration

This is a video demonstration of my robotic arm using the button control system.

Step 2: The Design Process: Robotic Arm #1

This image is of my first attempt at a robotic arm. It used all SG90 servos, but then, it didn't have much weight to move around. To attach the 3D printed parts to the servos, I removed the back of the servos and included a 3D printed servo back in the parts of the arm. I thought it was a great idea at the time, until I had to keep changing out the parts to make adjustments, which wasn't that easy.

This version was not meant to look good, just to demonstrate the principals of the robotic arm (the reason it looks nothing like the finished product).

Step 3: The Design Process: Robotic Arm #2

I modeled up this entire thing before printing, unlike the last version, where I modeled and printed as I went.

I added a degree of freedom (DOF) to this version and changed my method of attachment to the servos.

This version failed because the metal gear servos did not have enough torque to lift up the arm (which leads right into the next design).

Step 4: The Design Process: Robotic Arm #3

This version, I think, looked the best. I switched out the bottom servo with a high torque servo.

It worked great without the gripper assembly attached, but the second servo was unable to lift the weight of the arm. (I am assuming I missed this the first time because I was focused on the bottom servo not having enough torque.)

Step 5: The Design Process: the Final Robotic Arm

The final version of this arm looks slightly different then the previous two versions. I originally switched out the second servo for a high torque servo, but I ran into the problem of having to transition from a high torque servo (wider) to a micro servo (not as wide) in a bar. I couldn't seem to work out how that was going to work without it being ugly, so I just rooted the bottom servo to the ground, keeping the transition in the servo enclosure arm.

Step 6: Assembly: Print the Parts

I have grouped this arm into 5 sections:

  1. Base
  2. Axis 1
  3. Axis 2
  4. Axis 3
  5. Gripper

Each STL file name corresponds with the location of the part on the arm. For example, "base - support" would be a supporting piece in the "base" assembly.

I have included the .step file for this design for those who wish to view it.

To download the .stl files, visit this link.

Step 7: Assembly: Axis 1 - Servo Enclosure

For this step, you will need:

  • m2x8 screws (x8)
  • m2x10 hex standoffs (x4)
  • m3 nut (x3)
  • MG946R Servo (x1)
  • "axis1 - servoEnclosure - bottom"
  • "axis1 - servoEnclosure - top"

Slide a hex standoff into "axis1 - servoEnclosure - bottom". There are four hexagonal shaped slots surrounding the servo's location. Half of the standoff should be visible. Holding the standoff in place with your finger, flip the part over and insert an m2x8 screw into the hole corresponding with the standoff. Tighten this screw. Repeat this method with the other three standoffs and hexagonal slots.

Press the servo into its place. It will only be able to go in one way.

Take the 3 m3 nuts and place them in the hexagonal slots perpendicular to the standoff slots. There are two of these slots opposite the servo's cable and one slot is near the cable.

Take the "axis1 - servoEnclosure - top" part and place it on top of the current assembly, making sure everything remains in place as you do so. Use the remaining m2x8 screws to fasten the "top" to the "bottom."

The resulting assembly will be referenced as "Axis 1 - Servo Enclosure Assembly"

Step 8: Assemby: Axis 1 - Pivot Arm

For this step, you will need:

  • m3x8 screw (x1)
  • "pivotBearing"
  • "pivotSpacer" or m3 washers (x2)
  • "axis1 - pivotArm"
  • "Axis 1 - Servo Enclosure Assembly"

Slide the servo cable from the "Axis 1 - Servo Enclosure Assembly" through the slot on the "axis1 - pivotArm" (the "axis1 - pivotArm" is reversible, so it is your choice on which side you want showing).

Slide the "pivotSpacer" or 2 m3 washers on the m3 screw, followed by the "pivotBearing."

Line up the hole on the "axis1 - pivotArm" with the hole on the "Axis 1 - Servo Enclosure Assembly." use the m3 Screw assembly you just created to tighten the pivot arm to the servo enclosure. The pivot arm should be able to turn freely.

The resulting assembly will be refrenced as "Axis 1 - Assembly"

Step 9: Assembly: Axis 2 - Servo Enclosure

For this step, you will need:

  • m2x8 screws (x8)
  • m2x10 hex standoffs (x4)
  • MG946R Servo (x1)
  • SG52 metal gear servo (x1)
  • m3 nut (x2)
  • "axis2 - servoEnclosure - bottom"
  • "axis2 - servoEnclosure - top"

This step is almost exactly the same as step 7, except you will be inserting 2 servo motors into the enclosure, and only two m3 nuts are inserted into their slots.

The resulting assembly will be refrenced as "Axis 2 - Servo Enclosure Assembly"

Step 10: Assembly: Combine Axis 1 With Axis 2

For this step, you will need:

  • m3x8 screw (x1)
  • "pivotBearing"
  • "pivotSpacer" or m3 washers (x2)
  • "Axis 1 - Assembly"
  • "Axis 2 - Servo Enclosure Assembly"

Follow the same steps as step 8, except this time you will be attaching the pivot arm to the larger end of the "Axis 2 - Servo Enclosure Assembly." Remember to thread the servo's cable through the "c" slot in the pivot arm.

Step 11: Assembly: Axis 3 - Pivot Arm

Repeat the previous step with the "axis3 - pivotArm" and the smaller servo in the axis 2 servo enclosure.

Step 12: Technique: Attaching Servo Horns to 3D Printed Parts

This is the technique I use for attaching servo horns to 3D printed parts. This step is not part of the robotic arm assembly, it is a tutorial that you will need to use in later steps.

To use this technique, you will need:

  • Servo horn
  • 3D printed part with Servo Horn slot
  • stripped solid core wire

Step 13: Technique: Make the "staples"

Strip a section of the solid core wire and cut it in half. You want about 2 cm (the sections in my image are a little too small) for each wire.

Take a section and bend it in half. I do this by folding it over the shaft of a small screw driver. Do this for both wires.

You should now have 2 wire sections that resemble staples.

Step 14: Technique: Attach the Servo Horn

Place the servo horn in the slot.

Take a wire/staple and push it through the holes on the other side of the part. You may need to wiggle it around some to push it thought the 3D printed part holes and the servo horn holes. When I do this, I always push one end through the outer hole and push the other end through the hole after the second outer one. The holes you use will depend on how you bent the wires in the previous step of this technique.

Step 15: Assembly: Servo Horns and Servo Horn Arms

For this step, you will need:

  • Stripped wire
  • Double ball bearing servo - "+" shaped servo horn
  • Double ball bearing servo - "star" shaped servo horn
  • SG52 servo - "line" shaped servo horn (x2)
  • "axis1 - servoHornArm"
  • "axis3 - servoHornArm"
  • "gripper - hornAttachment"

Note: I am using the double ball bearing servo horns for the metal gear high torque servos because they are smaller and fit better into my design.

Using the technique from steps 12-14, attach the servo horns to their arms. Set these aside for later use.

Step 16: Assembly: the Base (part 1)

For this step, you will need:

  • "base - base"
  • "base - support" (x4)

Pres fit each "base - support" into the rectangular slots on the outsides of the "base - base" part. The wider openings on the "base - support" parts should be facing the center of the circle.

Step 17: Assembly: the Base (part 2)

For this step, you will need:

  • double ball bearing servo
  • "base - servoSupport"
  • "base - servoSupport - cable"
  • m4 nut (x4)
  • m4x12 screws (x4)

Slide two of the m4 nuts into the wider slots on the "base - servoSupport" and line up the holes with the holes on the double ball bearing servo. I put the wider opening of this part to the body of the servo to keep the nuts from falling out.

Use the m4x12 screws to fasten the "base - servoSupport" to the servo on the side without the cable.

Repeat these steps with the "base -servoSupport - cable" part. This piece will be fastened to the side of the servo with the cable (hence the name).

Finally, press this servo assembly into the holes on the "base - base" part. When complete, the rotational axis of the servo should be in line with the center of "base - base."

Set this aside for now.

Step 18: Assembly: Wrist Servo Enclosure

For this step, you will need:

  • "wrist - servoEnclosure - bottom"
  • "wrist - servoEnclosure - top"
  • "axis3 - plate"
  • m2x10 hex standoffs (x4)
  • m2x12 screws (x8)
  • SG52 metal gear servo motor
  • m3 nuts (x2)
  • m3x8 screws (x2)
  • m3 washers (x10)

This step is, again, almost identical to step 7, except with a smaller servo. Follow the same steps to enclose the servo in the parts. Don't forget to add the m3 nuts to their slots. (I forgot to do this one time, and when I went to attach this part to another part, it took me a long time to realize why the screw wasn't getting tight.)

Once you have the servo fully enclosed, attach the "axis3 - plate" to the enclosure using the m3x8 screws. You will need to offset the head of the screw with about 5 washers to keep the end of the screw from colliding with the servo on the inside of the enclosure.

Step 19: Assembly: Attach the Wrist to the Arm

For this step, you will need:

  • Arm assembly
  • wrist assembly
  • m3 nuts (x2)
  • m3x8 screws (x2)

Slide the m3 nuts into the slots on the "axis3 - pivotArm"

Take the cable side of the wrist assembly and line the holes up with the holes on the "axis3 - pivotArm." Fasten these two assemblies together with the m3 screws, keeping the edge of "axis3 - plate" flush with the outside of "axis3 - pivotArm."

Set this aside for later use.

Step 20: Assembly: the Gripper

Assembling the gripper will be a process for the next few steps. To build the gripper, you need:

  • "gripper - servoEnclosure - top"
  • "gripper - servoEnclosure - bottom"
  • "gripper - plate - back"
  • "gripper - plate - front"
  • "gripper - servoGear"
  • "gripper - rackGear" (x2)
  • "gripper - spacer" (x2)
  • "gripper - jaw" (x2)
  • SG90 servo
  • SG90 servo horn (any tipe)
  • m2 nuts (x8)
  • m2x16 screws (x4)
  • m2x8 screws (x4)
  • m3 nuts (x2)

Step 21: Assembly: the Gripper

To begin the assembly of the gripper, set the servo in the "gripper - servoEnclosure - bottom." This servo enclosure is slightly different than the others. For one, I forgot to add the holes on the outsides to attach each half together, but it turned out that these were not needed (you will understand why later).

Slide 2 m2 nuts in the slots near the top and 2 m3 nuts in the slots on the bottom.

Feed the cable through he slots in the part (view the image).

Take the other half of the servoEnclosure and slide 2 m2 nuts in the slots near the top (when the halves go together, there will be 4 m2 nuts inside). Keep the two halves vertical as you press them together in order to keep the m2 nuts in their places. You will also want to make sure the cable is not getting squished by the two halves.

I found it is helpful to tighten the m2 nuts near the top down with spare screws to keep them from moving on you as you put this part together. Just remove them when you are ready to attach the next part.

Set this part aside for the moment.

Step 22: Wiring: the Circuit

At this point in the build, it is necessary to make sure all servo motors are correctly centered. For this arm design, all servo motors need to be set at 90 degrees before they can be fixed to the parts. To do this, it is necessary to connect them to the Arduino.

This is part of this project that I am still working on. I will show you my test circuit and I will update when I have built something more permanent.

If you have ever connected servo motors to the Arduino, this will be fairly straightforward. For those of you who haven't, I suggest you do a quick internet search to familiarize yourself with this process (a search of "servo motor control Arduino" will do the trick).

To make this test circuit easy to assemble and disassemble, I used a double row of male pin headers (see image). I then cut these apart into sections of 3 (for each lead of the servo motors) I used a double row because they sit in the solder-less breadboard a lot better than just a single row would.

Since there are 6 servo motors in this arm, you will need 6 of these 3 pin header sections.

Step 23: Wiring: the Circut

Press each of the pin headers into the breadboard as shown in the image. Make sure to leave room in the rows to connect other wires.

Connect one of the outside pins of every 3 pin group to the blue bar on the breadboard. I suggest you pick the same pin on all of the sections to make the circuit neater and easier to understand.

Connect the center pin to the red bar on the breadboard.

Connect the blue bar to the GND on the Arduino (in my case, an Arduino Mega)

Connect the remaining pins of the pin header sections to digital ports 4-9 on the Mega. If you are using another board, you will need to connect these to digital ports with PWM capabilities and you will also need to edit the code to specify which ports you used.

Step 24: Wiring: the Circut

You are now going to need to create your power supply. I am still unsure if I did this right, but it hasn't blown up yet, so I think it is good.

You will need two battery packs that each hold 4 AA batteries. Connect the packs together in parallel by connecting like colors (black to black and red to red). This increases the amperage of the supply, but keeps the voltage at a level the servos can handle. When you are ready to run the servos, just connect the red wires to the red bar on the breadboard, and connect the black wires to the blue bar on the breadboard. When I did this, I used a smaller breadboard to make the connections.

Step 25: Programming: Center the Servos

Connect all of the servo motors to the angled pin headers on the breadboard like I did in the image above. Remember to connect the ground wire of the servo to the ground wire on the breadboard.

I set up my breadboard so that the first servo (the base) would be the first on the breadboard, and thus the lowest numbered port.

Upload this code to your Arduino:

#include <Servo.h>

Servo base;
Servo DOF1;
Servo DOF2;
Servo DOF3;
Servo wrist;
Servo gripper;



void setup(){
	base.attach(4);
  	DOF1.attach(5);
  	DOF2.attach(6);
  	DOF3.attach(7);
  	wrist.attach(8);
  	gripper.attach(9);
}

void loop() {
	base.write(90);
	DOF1.write(90);
	DOF2.write(90);
	DOF3.write(90);
	wrist.write(90);
	gripper.write(45); //the position with the gripper all the way open

}

Don't forget to plug in your power supply. You will need to keep this code running while you complete the assembly to be sure the servos stay centered.

You may want extension cables for the servo motors so they can reach from the Arduino to the motor. You can either buy some pre-made ones, or make your own. If you wish to make your own, just take a row of 3 male pin headers and solder on three wires. Solder a row of 3 female pin headers to the other end of those wires, and you have yourself a servo extension cable as seen above.

Step 26: Assembly: the Gripper

After that intermission, we can return to assembling the gripper.

Take the servo horn for the SG90 and clip off all of the horn pieces, leaving you with just the center piece that attaches to the servo. I used a pair of side dikes and then sanded down the rough edges.

Press fit this piece into the "gripper - servoGear" so that the top of the piece is flush with the top of the gear (The part that attaches to the servo will sit inside the gear itself)

*Note: Depending on the tolerance levels of your printer, you may need to edit the file to make a smaller or larger hole in the gear to get a good press fit.

Step 27: Assembly: the Gripper

Take the "gripper - plate - back" part and set it on top of the gripper servo enclosure. The hole in the back plate should fit over the odd shape in the servo "neck" (I am not sure if this is what it is actually called).

Press the gear onto the servo.

Step 28: Assembly: the Gripper

Take 2 m2 nuts and press them into the backside of the rack gears. Once again, you may need to adjust the tolerance to get a good press fit.

Place these 2 rack gears inside the slots on the back plate with the nut side down. They need to be in the exact same place as they appear in the image. Remember how the code set the gripper servo motor to be 40? That number is the open position for the gripper, and placing the rack gears in this orientation means you will assemble the gripper in the open position.

Step 29: Assembly: the Gripper

Take the "gripper - plate - top" and place it on top of the back plate. Slide m2 screws through the holes in the front plate, the back plate, and the servo enclosure. Tighten these screws to the m2 nuts inside of the servo enclosure. If these are tight enough, they will hold the two halves of the servo enclosure together.

Step 30: Assembly: the Gripper

Push 2 m2x8 screws through the holes in the "gripper - jaw" pieces. Slide the "gripper - spacer" parts on under the jaw piece.

Place these jaw pieces over the rack gears in the gripper assembly. Tighten the screws into the nuts under the rack gears.

The gripper is now complete.

Step 31: Assembly: Arm Assembly to the Axis 1 - Base

For this step, you will need:

  • "axis1 - base"
  • high torque medium servo horn (in the shape of a line)
  • arm assembly
  • m3x8 screws (x2)

Press fit the servo horn into the space on "axis1 - base"

Use m3x8 screws to fasten the "axis1 - base" to the arm assembly, keeping the side with the servo horn on the bottom.

Step 32: Assembly: Base Assembly to Arm Assembly

For this step, you will need:

  • Arm Assembly
  • "base - axis1 - support" (x2)
  • "base - support - spacer" (x4)
  • m2x16 screws (x8)
  • m2 nuts (x8)
  • base assembly

Slide m2 nuts into their slots on the "base - support" parts attached to the base assembly.

Place a "base - axis1 - support on top of the base assembly so that the holes align with the holes in the "base - support" parts.

Place the arm assembly on top of the base double ball bearing servo (use the servo horn placed in the "axis1 - base" part). Since this is the base, the angle this piece is at is not crucial to the function of the arm, just the appearance. If you want the centered arm to line up with a cretin point, then make sure to do that when you place this part down. If you are not that particular, then you can place it down however you like.

Slide the m2 screws through the other "base - axis1 - support," followed by the four "base - support - spacer" parts (one on each quarter of the ring). Slide this assembly over the top of the arm with the screws pointing down. Line up the screws with the holes in the "base - axis1 - support" beneath the "axis1 - base" and tighten them into the nuts located in the "base - support" parts.

The base should now be attached to the arm assembly.

*Note: this assembly can be a little tricky. It helps if you disassemble the arm a little (remove axis1 - servo enclosure from axis1 - pivot support) and reassemble after you complete this step.

Step 33: Assembly: Axis 1 - Servo Horn Arm

For this step, you will need:

  • "axis1 - servoHornArm" with servo horns attached
  • arm assembly
  • m3x8 screws (x2)

All of the servo motors should be set at 90 degrees, their center position. This means, when we incorporate the servo heads into the arm, we need to make sure the arm is at its center position. In the case of this arm, the center position is straight up and down. Move the "axis1 - pivotArm" and the Axis 2 Servo Enclosure so they are pointing straight up and away from the base.

Snap the "axis1 - servoHornArm" with the servo horns attached to the high torque servo in the Axis 1 Servo Enclosure and the high torque servo in the Axis 2 Servo Enclosure. Remember to keep the arm straight.

Use the m3x8 screws to tighten the servo horn arm to the servo motors.

Step 34: Assembly: Axis 3 - Servo Horn Arm

For this step, you will need:

  • arm assembly
  • "axis3 - servoHornArm" with servo horn attached
  • SG52 set screw (m2.5x3)
  • m3x8 screws (x2)
  • m3 nuts (x2)

Following the same steps from the last step, make sure axis 3 is pointing straight up, and attach the "axis3 - servoHornArm" to the servo in the axis 2 servo enclosure. Use the set screw that came with the servo motor to tighten the arm to the servo.

Slide the m3 nuts into their slots in the "axis3 - servoHornArm" and line up the holes with those on the "axis3 - base." Use the m3 screws to tighten the arm to the base.

Step 35: Assembly: Arm Assembly to Gripper

For this step, you will need:

  • Gripper assembly
  • "gripper - hornAttachment" with servo horn attached
  • m3x8 screws (x2)
  • SG52 set screw (m2.5x3)
  • Arm Assembly

Place the "gripper - hornAttachment" with the servo horn attached onto the wrist servo motor. You want the longer edge of the "gripper - hornAttachment" to be parallel with the longer edge of the wrist servo enclosure. Tighten it down using the servo set screw.

You can now unplug the power supply to turn the servos off. Use your hand to rotate the "gripper - hornAttachment" so that one of the two holes on the bottom side is exposed. Place the gripper assembly on top of the plate and align the holes. Use the m3 screws to tighten the gripper assembly to the arm assembly.

Step 36: Assembly: Completion

Congratulations! You are done assembling the arm. For this step, you can just admire your hard work and prepare yourself to program the arm.

Step 37: Wiring: Button Control

For this step, you will need:

  • Tactile switches/ buttons (x12)
  • Jumper cables (male to male)
  • solderless breadboard
  • Arduino and Servo circuit

Connect all 12 switches to the Arduino using this method:

Press each switch into the breadboard (usually, the center of the switch fits over the center bar). I grouped mine into twos with a larger space in between each group.

Connect the left pin of the button to the blue bar on the breadboard. Connect the right pin to a digital port on the Arduino.

Digital Port Connections:

I made this as simple as possible and connected the switches in order. To make this easier to explain, I will refer to each switch starting from the left as SW1, SW2, and so on.

SW1 = D22

SW2 = D23

SW3 = D26

SW4 = D27

SW5 = D30

SW6 = D31

Are you noticing a pattern? I was used the Arduino Mega for this project, which explains the high digital port numbers. The first 2 buttons I connected to the two digital ports next to eachother. I then skipped a row, and did the same. I repeated this pattern until I ran out of switches to connect.

SW7 = 34

SW8 = 35

SW9 = 38

SW10 = 39

SW11 = 42

SW12 = 43

Don't forget to connect the blue bar on the breadboard to the GND port on the Arduino, otherwise you will sit for at least 5 minutes staring at your code trying to figure out what you forgot (I am speaking from experience here).

Step 38: Programming: Button Control

One button will turn a servo one direction, and the other will turn that same servo the other direction.

One button will open the gripper, and the other will close the gripper (to be 10mm wide, which is the width of the blocks I 3D printed to move around)

#include <Servo.h>

Servo base;
Servo DOF1;
Servo DOF2;
Servo DOF3;
Servo wrist;
Servo gripper;


int baseLEFT = 22;
int baseRIGHT = 23;

int DOF1LEFT = 26;
int DOF1RIGHT = 27;

int DOF2LEFT = 30;
int DOF2RIGHT = 31;

int DOF3LEFT = 34;
int DOF3RIGHT = 35;

int wristLEFT = 38;
int wristRIGHT = 39;

int gripperRIGHT = 42;
int gripperLEFT = 43;


int baseANGLE = 90;
int DOF1ANGLE = 90;
int DOF2ANGLE = 90;
int DOF3ANGLE = 90;
int wristANGLE = 90;
int gripperANGLE = 40;

int angleStep = 5; //This variable controls the speed at which the servos turn

int d = 2;


int gripperOPEN = 45;
int gripper10 = 90;
int gripperCLOSED = 115;


void setup() {
  pinMode(baseLEFT, INPUT_PULLUP);
  pinMode(baseRIGHT, INPUT_PULLUP);

  pinMode(DOF1LEFT, INPUT_PULLUP);
  pinMode(DOF1RIGHT, INPUT_PULLUP);

  pinMode(DOF2LEFT, INPUT_PULLUP);
  pinMode(DOF2RIGHT, INPUT_PULLUP);

  pinMode(DOF3LEFT, INPUT_PULLUP);
  pinMode(DOF3RIGHT, INPUT_PULLUP);

  pinMode(wristLEFT, INPUT_PULLUP);
  pinMode(wristRIGHT, INPUT_PULLUP);

  pinMode(gripperLEFT, INPUT_PULLUP);
  pinMode(gripperRIGHT, INPUT_PULLUP);

  
  
  
  
  
  base.attach(4);
  DOF1.attach(5);
  DOF2.attach(6);
  DOF3.attach(7);
  wrist.attach(8);
  gripper.attach(9);


  gripper.write(40);

  Serial.begin(9600);  

  setServos90();

}

void loop() {

  setServosButton();
  writeGripperPosition();
  delay(20);

}

void writeGripperPosition() {
  
  if (digitalRead(gripperLEFT) == LOW) {
    
    gripper.write(gripperOPEN); // open
    
  }
  
  if (digitalRead(gripperRIGHT) == LOW){
    
    gripper.write(gripper10); //10 mm closed
    
  } 
  
}

void setServos90() {
  base.write(90);
  DOF1.write(90);
  DOF2.write(90);
  DOF3.write(90);
  wrist.write(90);
  }


void setServosButton(){

//Base
  
  if (digitalRead(baseRIGHT) == LOW){
    
    if (baseANGLE >= 0 && baseANGLE <= 180) {
      baseANGLE = baseANGLE - angleStep;
        if (baseANGLE < 0){
          baseANGLE = 0;
        } else {
          base.write(baseANGLE);
        }
    }
    
  }

  delay(d);
  
  if (digitalRead(baseLEFT) == LOW){
    
    if (baseANGLE >= 0 && baseANGLE <= 180) {
      baseANGLE = baseANGLE + angleStep;
        if (baseANGLE > 180){
          baseANGLE = 180;
        } else {
          base.write(baseANGLE);
        }
    }
    
  }

  delay(d);

//DOF1

  if (digitalRead(DOF1RIGHT) == LOW){
    
    if (DOF1ANGLE >= 0 && DOF1ANGLE <= 180) {
      DOF1ANGLE = DOF1ANGLE - angleStep;
        if (DOF1ANGLE < 0){
          DOF1ANGLE = 0;
        } else {
          DOF1.write(DOF1ANGLE);
        }
    }
    
  }

  delay(d);
  
  if (digitalRead(DOF1LEFT) == LOW){
    
    if (DOF1ANGLE >= 0 && DOF1ANGLE <= 180) {
      DOF1ANGLE = DOF1ANGLE + angleStep;
        if (DOF1ANGLE > 180){
          DOF1ANGLE = 180;
        } else {
          DOF1.write(DOF1ANGLE);
        }
    }
    
  }

  delay(d);

//DOF2

  if (digitalRead(DOF2RIGHT) == LOW){
    
    if (DOF2ANGLE >= 0 && DOF2ANGLE <= 180) {
      DOF2ANGLE = DOF2ANGLE - angleStep;
        if (DOF2ANGLE < 0){
          DOF2ANGLE = 0;
        } else {
          DOF2.write(DOF2ANGLE);
        }
    }
    
  }

  delay(d);
  
  if (digitalRead(DOF2LEFT) == LOW){
    
    if (DOF2ANGLE >= 0 && DOF2ANGLE <= 180) {
      DOF2ANGLE = DOF2ANGLE + angleStep;
        if (DOF2ANGLE > 180){
          DOF2ANGLE = 180;
        } else {
          DOF2.write(DOF2ANGLE);
        }
    }
    
  }

  delay(d);

//DOF3

  if (digitalRead(DOF3RIGHT) == LOW){
    
    if (DOF3ANGLE >= 0 && DOF3ANGLE <= 180) {
      DOF3ANGLE = DOF3ANGLE - angleStep;
        if (DOF3ANGLE < 0){
          DOF3ANGLE = 0;
        } else {
          DOF3.write(DOF3ANGLE);
        }
    }
    
  }

  delay(d);
  
  if (digitalRead(DOF3LEFT) == LOW){
    
    if (DOF3ANGLE >= 0 && DOF3ANGLE <= 180) {
      DOF3ANGLE = DOF3ANGLE + angleStep;
        if (DOF3ANGLE > 180){
          DOF3ANGLE = 180;
        } else {
          DOF3.write(DOF3ANGLE);
        }
    }
    
  }

  delay(d);

//wrist

  if (digitalRead(wristRIGHT) == LOW){
    
    if (wristANGLE >= 0 && wristANGLE <= 180) {
      wristANGLE = wristANGLE - angleStep;
        if (wristANGLE < 0){
          wristANGLE = 0;
        } else {
          wrist.write(wristANGLE);
        }
    }
    
  }

  delay(d);
  
  if (digitalRead(wristLEFT) == LOW){
    
    if (wristANGLE >= 0 && wristANGLE <= 180) {
      wristANGLE = wristANGLE + angleStep;
        if (wristANGLE > 180){
          wristANGLE = 180;
        } else {
          wrist.write(wristANGLE);
        }
    }
    
  } 
  
}






Step 39: Final Word

That was a long one. Thanks for taking the time to view this Instructable. I hope you were able to learn something or get some inspiration. As always, if you have any questions, comments, concerns, or criticism (Yes, even the criticism. I won't be offended.), don't hesitate to leave a comment. I know this project isn't perfect, and it can get a lot better with your help.

I will be updating this project when I make a few things more permanent, such as doing away with the solderless breadboards and building a button controller, as well as adding inverse kinematics (my current plan is to control the arm using my 3D Printed Arduino Based RC Controller when I complete the inverse kinematics). I will also try to update this project as I make more design modifications.

Thanks,

BasementMaker

Robots Contest

First Prize in the
Robots Contest

Be the First to Share

    Recommendations

    • Pets Challenge

      Pets Challenge
    • Fandom Contest

      Fandom Contest
    • Water Speed Challenge

      Water Speed Challenge

    11 Comments

    0
    kjellgnilsson.kn
    kjellgnilsson.kn

    Question 10 months ago on Step 6

    Where do I find the printable .stl files?

    0
    BasementMaker
    BasementMaker

    Answer 10 months ago

    I have uploaded the .stl files to Thingiverse. You can find the link in step 6. Sorry for the wait.

    -BasementMaker

    0
    kjellgnilsson.kn
    kjellgnilsson.kn

    Reply 10 months ago

    Thank you for the added the .stl files in your Arduino Robotic Arm project, it will help a lot.

    0
    BasementMaker
    BasementMaker

    Answer 10 months ago

    You can download the .step file and open it in a CAD software like Fusion 360 to convert each part to a .stl. If that doesn't work or you are unable to do that, please let me know and I can include all of the individual .stl files in this instructable.

    0
    kjellgnilsson.kn
    kjellgnilsson.kn

    Reply 10 months ago

    Thank you. Unfortunately I don't have Fusion 360 or know how it work. I usually work with TinkerCad. But TinkerCad doesn't support the .step format.
    I would appreciate if you can add the .stl files to your interesting project or mail them to me directly.
    Best regards,
    Kjell Nilsson in Sweden

    0
    BasementMaker
    BasementMaker

    Reply 10 months ago

    Sure thing. It may take me a few days to get those posted, but I will do it.

    0
    chenc14
    chenc14

    Question 10 months ago on Step 6

    Hi, how do I separate each part to print?

    0
    BasementMaker
    BasementMaker

    Answer 10 months ago

    Hello. If you download the .step file, you should be able to open it up in a CAD software such as Fusion 360, where you can convert each part into an .stl file. If that dosn't work, or you are unable to do that, let me know and I can include all of the individual .stl files.

    0
    chenc14
    chenc14

    Reply 10 months ago

    Haha, sorry for that. I mean I'm not sure how to convert each part to stl file, but never mind let me try how to convert. Thanks for designing the cool robotic arm.