Arduino Web controlled Robotic arm
This project aims to control the movement of a robotic arm by a computer through the internet.
The robot is controlled by Arduino Uno interfaced with the internet using Arduino WiFi Shield in order to do some basic functions.
Hardware Required
Arduino Uno
Wifi Shield
6 degree of freedom Robotic Arm
Software Required
Arduino IDE
1:- Arduino UNO
It is like a brain of the robot, with the help of this board we can make different DIY projects like electronic, mechanical, automation etc projects. Arduino UNO works on C and C++ language called Arduino IDE. Technically Arduino UNO is an open source electronic based hardware and software platform, it is easy to use. Arduino UNO boards are able to read digital and analogs inputs as well, sensors, a finger on buttons & turn it into an output - activate motors, turning on LEDs and many more.
2: 6DOF Robot Arm
Robot Arm is used to do specific repetitive task. It used in many industrial applications. It is designed to perform any desired task such as welding, placing, gripping, spinning, rotating boxes etc depending on the application such as in manufacturing plant for welding, in production for assembling etc. You can buy it onlinec
3: WiFi shield
WiFi Module is a self contained SOC with integrated TCP/IP protocol stack which can give access to microcontroller for your WiFi network. The Arduino WiFi shield allows an Arduino UNO board to connect to the internet.
CODE
#include "SPI.h"
#include "Phpoc.h"
#include int angle_init[] = {90, 101, 165, 153, 90, 120};
int angle_offset[] = {0, 11, -15, -27, 0, 137};
int cur_angles[] = {90, 101, 165, 153, 90, 120};
int dest_angles[] = {0, 0, 0, 0, 0, 0};
int angle_max[] = {180, 180, 160, 120, 180, 137};
int angle_min[] = { 0, 0, 0, 20, 0, 75};
int direction[] = {1, 1, 1, 1, 1 ,-1};
int angleSteps[] = {3, 2, 2, 2, 4 ,4};
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;
Servo servo[6] = {servo1, servo2, servo3, servo4, servo5, servo6};
PhpocServer server(80);
PhpocClient client;
int stepNum = 0;
void setup()
{ Serial.begin(9600);
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
server.beginWebSocket("remote_arm");
servo1.attach(2);
servo2.attach(3);
servo3.attach(4);
servo4.attach(5);
servo5.attach(6);
servo6.attach(7);
for(int i = 0; i < 6; i++)
servo[i].write(angle_init[i]); }
void loop()
{ PhpocClient client = server.available();
if(client)
{ String angleStr = client.readLine();
if(angleStr)
{ Serial.println(angleStr);
int commaPos1 = -1;
int commaPos2;
for(int i = 0; i < 5; i++)
{ commaPos2 = angleStr.indexOf(',', commaPos1 + 1);
int angle = angleStr.substring(commaPos1 + 1, commaPos2).toInt();
dest_angles[i] = angle * direction[i] + angle_offset[i];
commaPos1 = commaPos2; }
int angle5 = angleStr.substring(commaPos1 + 1).toInt();
dest_angles[5] = angle5 * direction[5] + angle_offset[5];
stepNum = 0; for(int i = 0; i < 6; i++) { int dif = abs(cur_angles[i] - dest_angles[i]);
int step = dif / angleSteps[i];
if(stepNum < step) stepNum = step; }
}
}
if(stepNum > 0) { for(int i = 0; i < 6; i++)
{ int angleStepMove = (dest_angles[i] - cur_angles[i]) / stepNum; cur_angles[i] += angleStepMove;
if(cur_angles[i] > angle_max[i]) cur_angles[i] = angle_max[i];
else if(cur_angles[i] < angle_min[i]) cur_angles[i] = angle_min[i];
servo[i].write(cur_angles[i]); }
stepNum--;
delay(20); }
}