Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Gesture-Controlled Robotic Arm with Arduino Nano and MPU-6050

View and Edit Project In Cirkit DesignerImage of Gesture-Controlled Robotic Arm with Arduino Nano and MPU-6050

Circuit Documentation

Summary

The circuit in question is designed to control a robotic arm using gesture inputs detected by an MPU-6050 sensor. The arm is actuated by four servo motors, which are controlled by an Arduino Nano microcontroller. The MPU-6050 provides real-time feedback on the arm's orientation, which is then used to adjust the position of the servos accordingly. A flex resistor is used to control the gripper mechanism of the robotic arm. The entire system is powered by a 5V battery.

Component List

Servo Motors

Arduino Nano

MPU-6050

Basic Flex Resistor

Resistor (200 Ohms)

5V Battery

Wiring Details

Servo Motors

Arduino Nano

MPU-6050

Basic Flex Resistor

Resistor (200 Ohms)

5V Battery

Documented Code

//Code for Gesture Controlled Robotic ARM (Arduino Nano & MPU6050)

//Circuit Digest

#include<Wire.h>                //I2C Wire Library 

#include<Servo.h>               //Servo Motor Library

Servo servo_1;      
Servo servo_2;
Servo servo_3;
Servo servo_4;

const int MPU_addr=0x68;        //MPU6050 I2C Address
int16_t axis_X,axis_Y,axis_Z;
int minVal=265;
int maxVal=402;

double x;
double y;
double z;

void setup()
{
  Serial.begin(9600);
  
  Wire.begin();                      //Initialize I2C Communication
  Wire.beginTransmission(MPU_addr);  //Start communication with MPU6050
  Wire.write(0x6B);                  //Writes to Register 6B
  Wire.write(0);                     //Writes 0 into 6B Register to Reset
  Wire.endTransmission(true);        //Ends I2C transmission
  
  servo_1.attach(2);   // Forward/Reverse_Motor
  servo_2.attach(3);   // Up/Down_Motor
  servo_3.attach(4);   // Gripper_Motor
  servo_4.attach(5);   // Left/Right_Motor
  
}

void loop()
{
  Wire.beginTransmission(MPU_addr);    
  Wire.write(0x3B);                  //Start with register 0x3B 
  Wire.endTransmission(false);     
  Wire.requestFrom(MPU_addr,14,true);  //Read 14 Registers 
  
  axis_X=Wire.read()<<8|Wire.read();                //Reads the MPU6050 X,Y,Z AXIS Value
  axis_Y=Wire.read()<<8|Wire.read();
  axis_Z=Wire.read()<<8|Wire.read();
  
  int xAng = map(axis_X,minVal,maxVal,-90,90);     // Maps axis values in terms of -90 to +90  
  int yAng = map(axis_Y,minVal,maxVal,-90,90);
  int zAng = map(axis_Z,minVal,maxVal,-90,90);
       
  x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);       //Formula to convert into degree
  y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI);
  z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI);

  int gripper;
  int flex_sensorip = analogRead(A0);            //Reads flex sensor output
     
  if(flex_sensorip > 750)
        {
          gripper = 0;
        }
        else
        {
          gripper = 180;
        }
  
   servo_3.write(gripper);                    //Writes gripper value to 3rd servo motor
  
  if(x >=0 && x <= 60) 
  {
     int mov1 = map(x,0,60,0,90);
     Serial.print("Movement in F/R = ");
     Serial.print(mov1);
     Serial.println((char)176);
     servo_1.write(mov1);
  } 
 
  else if(x >=300 && x <= 360) 
  {
     int mov2 = map(x,360,250,0,180);
     Serial.print("Movement in Up/Down = ");
     Serial.print(mov2);
     Serial.println((char)176);
     servo_2.write(mov2);
  } 

 if(y >=0 && y <= 60) 
  {
     int mov3 = map(y,0,60,90,180);
     Serial.print("Movement in Left = ");
     Serial.print(mov3);
     Serial.println((char)176);
     servo_4.write(mov3);
  } 
 
  else if(y >=300 && y <= 360) 
  {
     int mov3 = map(y,360,300,90,0);
     Serial.print("Movement in Right = ");
     Serial.print(mov3);
     Serial.println((char)176);
     servo_4.write(mov3);
  } 
}

This code is designed to be uploaded to an Arduino Nano microcontroller. It initializes the MPU-6050 sensor and the servo motors in the setup() function. In the loop() function, it reads the sensor data, processes it, and then controls the servo motors to move the robotic arm based on the sensor input. The flex sensor reading is used to control the gripper servo.