Robotic Arm With Servo - Anica, Merrick and Declan
by PHS_Engineering in Circuits > Arduino
279 Views, 1 Favorites, 0 Comments
Robotic Arm With Servo - Anica, Merrick and Declan
This is how to build a simple robotic arm that you can create using Arduino! It moves via servo motors controlled by potentiometers, and it also includes an electromagnet on the end to pick things up. The "frame" of the arm we have constructed out of light wood, but this is optional and you can really use whatever you want as a "frame" so long as it works.
Supplies
1. Arduino
2. Two potentiometers
3. Two servo motors
4. Breadboard
5. Three light pieces of wood
6. Assorted wires
7. simple electromagnet
8. 9volt battery
9. Alligator wires
Create Circuit
For this circuit you will be using your bread board, wires, 2 servos, 2 potentiometers, and your arduino. Both servos should have a red, orange and a black wire. I think it is helpful to keep those same colors so you know where everything goes. Red should connect to your positive row. Black should connect to your negative row. Orange should connect to your pins. I put one in pin 6 and one in pin 11. Your potentiometer has three metal points, two on the top and one on the bottom. If your pin is oriented like this, then the top left is positive, the top right is negative and the bottom should connect to A0 and A1. Your positives and negative should connect to the opposite positive and negative row than what you used before. The positive row should connect to 5V, and the negative row should connect to ground.
Getting Materials for Frame
At this point you will need something to be the "frame" of your robotic arm. This just means a material that can be used for your arm which can be attached to the servos. We have used a light wood for our frame but that is not necessary, and you could use anything that works, (wood, cardboard, etc.) After planning our measurements, (7'' up 3'' out, 8'' down), we cut the pieces of wood using a band saw. You also need something to act as a base, again we used wood scraps but you can get creative.
Coding
The code will be written out below. But if you want to do it yourself I will also give you some instructions. The first thing you need to do is attach the library servo.h You will then need to define your variables that connect to both potentiometers and both servos. You will need to map your potentiometer value. You will need to create an if statement so that when your potentiometer is at a certain level your servo will turn on. If you need more instruction you can look at the code linked below.
#include "Servo.h"
Servo myServo; // the variable for the first servo
Servo myServo1; // the variable for the second servo
int servoPin=9; // the servo connecting to the first pin
int servoPin2=6; // the servo connecting to the second pin
int potPin=A0; // the potentiometer connecting to the first pin
int potPin1=A1; // the potentiometer connecting to the first pin
void setup() { // put your setup code here, to run once:
Serial.begin(9600); // connecting to the serial monitor
pinMode (potPin,INPUT); // connecting the first potentiometer to the input
pinMode (potPin1,INPUT); // connecting the second potentiometer to the input
myServo.attach(servoPin); // attaches the first servo to variable
myServo1.attach(servoPin2); // attaches the second servo to variable
}
void loop() { // put your main code here, to run repeatedly:
int value=analogRead(potPin); // reads value of first potentiometer
int angle=map (value,0,1023,0,180); // maps value of first potentiometer
myServo.write(angle); // connects angle to servo
Serial.println(value); // connects value
delay (20);
int value1=analogRead(potPin1); // reads value of second potentiometer
int angle1 = map(value1,0,1023,0,180); // maps value of second potentiometer
myServo1.write(angle1); // connects angle to servo
Serial.println(value1); // connects value to servo
delay(20);
}
Assembling the Base
Pretty simple, you need to make your base. We used a large flat wood scrap with a smaller, thicker wood piece attached with which to affix the arm frame. The base should allow you to be able to attach your arm frame, as well as being wide and sturdy enough to support the weight of the finished arm without tipping over. Because of this it should probably be constructed tighter, we used screws as well as wood glue.
Assembling the Arm
This is the point where you attach your servo motors to the wooden frame. We used a hot glue gun and electrical tape to affix them, and we also taped down the wires. At this point you have your code and you should be able to test out your arm and see if it is rotating properly.
Assembling the Electromagnet
This just requires a simple electromagnet, it has to be light enough to attach to the arm and small enough to be able to be powered with a 9volt battery, but of course you can play around with the materials. We used alligator clips to attach the positive and negative ends of the 9volt battery to the positive and negative ends of the magnet. We added a button to the circuit so it creates a way to drop whatever it picks up.
Attaching the Electromagnet to the Arm
In this step you attach your (hopefully) working electromagnet to the arm. We simply used electrical tape to attach both magnet and alligator wires to the arm. The one complication of this step is that you have to make sure the magnet apparatus isn't too heavy for your arm/servos to handle.