In this project we will learn how to make a servo motorized robotic arm using Arduino. Our robotic arm can move in different directions. There are many types of Arduino available in the market but we are using Arduino UNO for this project. We use servo motors to control the movement of the robotic arm. If you don't know how to run a servomotor with an Arduino, check it out here. We can move the robotic arm in the desired direction with the help of the joystick unit. Also check that the Joystick module is connected to the Arduino module. Please make the circuit according to the circuit diagram and then upload the Arduino code which was provided at last.
Our robotic arm can move in both positive and negative(2-D) X and Y axis with the help of two servo motors. We use the joystick unit to give commands. We can control the movement of the servo motors through it. Mount one servo motor to the other using the accessories or you can also use a piece of cardboard so that both can comfortably move in the desired direction. After completing all the actions, just move the joystick in a random direction and your robotic arm will follow your commands. The benefits of using a servo motor is that we can easily control its position and the degrees we want it to move. The response of the robotic arm is very fast and you can control it according to your choice.
In this project we used the following components:
pie chart
robotic arm code
#include <Servo.h>
const int servo1 = 8; // first servo
const int servo2 = 9; // second servo
const int joyx = 0; // joystick module
const int joyy = 1; // // joystick module
int servoVal; // read the value from the analog pin
Servo myservo1; // create servo object to control a servo
Servo myservo2;
void setup() {
Serial.begin(9600);
myservo1.attach(servo1);
myservo2.attach(servo2);
}
void loop(){
servoVal = analogRead(joyx);
servoVal = map(servoVal, 0, 1023, 0, 180); // set the position of the first servo
myservo2.write(servoVal);
servoVal = analogRead(joyy);
servoVal = map(servoVal, 0, 1023, 70, 180); // set the position of the second servo
myservo1.write(servoVal);
delay(15);
}