New Project

CONNECT

Robot Arm Control With Hand Movement

  • Page Views 2479
  • Spread the love
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  

    The robot arm can be controlled in several ways.This project is not controlled by hand gestures, arm allows us to control more comfortable and precise.

    The components used in the project:

    • Arduino Nano
    • Arduino Uno
    • Adlx-345 3-axis accelerometer 2 Units
    • 5 Number 9 g servo motor
    • 2 pieces for the mechanical portion of the A4 mica

    Circuit diagram:

    Arduino Code:

    Two Servo Control:

    #include <Wire.h>
    #include <Servo.h>
    Servo myservox;
    Servo myservoy;
    #define DEVICE (0x53)
    #define TO_READ (6)
    #define TRIGGER 16
    byte buff[TO_READ] ;
    int i;
     
    void setup()
    {
    pinMode(TRIGGER,OUTPUT);
    digitalWrite(TRIGGER,HIGH);
    Wire.begin();
    myservox.attach(9);
    myservoy.attach(10);
    myservox.write(90);
    delay(25);
    myservoy.write(90);
    delay(25);
     
    writeTo(DEVICE, 0x2D, 0);
    writeTo(DEVICE, 0x2D, 16);
    writeTo(DEVICE, 0x2D, 8);
    }
     
    void loop()
    {
    int regAddress = 0x32;
    int x, y, z;
    digitalWrite(TRIGGER,LOW);
    delay(10);
    digitalWrite(TRIGGER,HIGH);
    readFrom(DEVICE, regAddress, TO_READ, buff);
     
    x=0;
    y=0;
    z=0;
    for(i=1;i<=5;i++){
    x += (((int)buff[1]) << 8) | buff[0];
    y += (((int)buff[3])<< 8) | buff[2];
    z += (((int)buff[5]) << 8) | buff[4];
    delay(10);
    }
    x/=5;
    y/=5;
    z/=5;
    if(x<-255)x= -255; else if (x>255)x=255;
    if(y<-255)y= -255; else if (y>255)y=255;
    x=map(x, -255, 255, 0, 180);
    y=map(y, -255, 255, 0, 180);
    myservox.write(x);
    delay(25);
    myservoy.write(180-y);
    delay(25);
     
    delay(200);
    }
     
    void writeTo(int device, byte address, byte val) {
    Wire.beginTransmission(device);
    Wire.write(address);
    Wire.write(val);
    Wire.endTransmission();
    }
     
    void readFrom(int device, byte address, int num, byte buff[]) {
    Wire.beginTransmission(device);
    Wire.write(address);
    Wire.endTransmission();
     
    Wire.beginTransmission(device);
    Wire.requestFrom(device, num);
     
    int i = 0;
    while(Wire.available())
    {
    buff[i]= Wire.read();
    i++;
    }
    Wire.endTransmission();
    }

    3 Servo Control

    #include <Wire.h>
    #include <Servo.h>
    Servo myservox;
    Servo myservoy;
    Servo kiskac_servo;
    int potpin = 0;
    int val;
    #define DEVICE (0x53)
    #define TO_READ (6)
    #define TRIGGER 16
    byte buff[TO_READ] ;
    int i;
     
    void setup()
    {
    pinMode(TRIGGER,OUTPUT);
    digitalWrite(TRIGGER,HIGH);
    Wire.begin();
    myservox.attach(9);
    myservoy.attach(10);
    kiskac_servo.attach(11);
    myservox.write(90);
    delay(25);
    myservoy.write(90);
    delay(25);
    kiskac_servo.write(90);
     
    writeTo(DEVICE, 0x2D, 0);
    writeTo(DEVICE, 0x2D, 16);
    writeTo(DEVICE, 0x2D, 8);
    }
     
    void loop()
    {
    int regAddress = 0x32;
    int x, y, z;
    digitalWrite(TRIGGER,LOW);
    delay(10);
    digitalWrite(TRIGGER,HIGH);
    readFrom(DEVICE, regAddress, TO_READ, buff);
     
    x=0;
    y=0;
    z=0;
    for(i=1;i<=5;i++){
    x += (((int)buff[1]) << 8) | buff[0];
    y += (((int)buff[3])<< 8) | buff[2];
    z += (((int)buff[5]) << 8) | buff[4];
    delay(10);
    }
    x/=5;
    y/=5;
    z/=5;
    if(x<-255)x= -255; else if (x>255)x=255;
    if(y<-255)y= -255; else if (y>255)y=255;
    x=map(x, -255, 255, 0, 180);
    y=map(y, -255, 255, 0, 180);
    myservox.write(x);
    delay(25);
    myservoy.write(180-y);
    delay(25);
    val = analogRead(potpin);
    val = map(val, 0, 1023, 0, 179);
    kiskac_servo.write(val);
     
    delay(200);
    }
     
    void writeTo(int device, byte address, byte val) {
    Wire.beginTransmission(device);
    Wire.write(address);
    Wire.write(val);
    Wire.endTransmission();
    }
     
    void readFrom(int device, byte address, int num, byte buff[]) {
    Wire.beginTransmission(device);
    Wire.write(address);
    Wire.endTransmission();
     
    Wire.beginTransmission(device);
    Wire.requestFrom(device, num);
     
    int i = 0;
    while(Wire.available())
    {
    buff[i]= Wire.read();
    i++;
    }
    Wire.endTransmission();
    }

     

     

     

    Share

    One Comment For "Robot Arm Control With Hand Movement"

    Leave a comment

    Your email address will not be published. Required fields are marked *

    BE A FACEBOOK FAN

    Instagram