Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Varun walimbe
Published © GPL3+

Gesture Controlled Car

This is a Robot Car that cane be controlled by hand gestures. how fun it will be?! :)

IntermediateFull instructions provided4 hours14,149
Gesture Controlled Car

Things used in this project

Hardware components

Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
One will be used for transmitting data and other one will be used for receiving data
×2
Rf 433mhz module
×1
Breadboard (generic)
Breadboard (generic)
×4
Jumper wires (generic)
Jumper wires (generic)
×1
Inertial Measurement Unit (IMU) (6 deg of freedom)
Inertial Measurement Unit (IMU) (6 deg of freedom)
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
chasis
×1
Robot Wheels
×1
Geared DC Motor, 12 V
Geared DC Motor, 12 V
×2
9V battery (generic)
9V battery (generic)
×2
Snap-on Connector, For 1 9-V Battery
Snap-on Connector, For 1 9-V Battery
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Tape, Double Sided
Tape, Double Sided
Scissor, Electrician
Scissor, Electrician

Story

Read more

Schematics

i2_jq7Ri6NBOd.JPG

Receiver Schematic

Transmitter Schematic

Code

Trsmitter_code.ino

Arduino
#include <RH_ASK.h> //Radio head ASK Library
#include <SPI.h>
#include <Wire.h>       //For communicate
#include <I2C.h>     //For communicate with MPU6050
#include <MPU6050.h>  //The main library of the MPU6050

RH_ASK rf_driver; 
MPU6050 mpu;       // Instance of MPU6050
int16_t ax, ay, az;
int16_t gx, gy, gz;

int X =0;  // variables  for storing  values of ax and ay
int Y =0;

//variables for storing int values of ax and ay as string
String accel; 
String gyro;
String str_out;

void setup() 
{
  mpu.initialize(); // wake up MPU6050
  Wire.begin();     //  necessary for I2C communication
  rf_driver.init();  Instance of ASK
  Serial.begin(9600); setting up Baud Rate as 9600
}

void loop() 
{
  delay(100);
   mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);  // get the values of ax, ay, az and gx, gy, gz

  X = map(az, -17000, 17000, 300, 600);    //Send X axis data
  Y = map(ay, -17000, 17000, 0, 300);     //Send Y axis data

  ax =  X; 
  ay =  Y;

  accel = String(ax); //int to String Conversion
  gyro =  String(ay);
  str_out = accel + "," + gyro; //combine the values for sending to other Arduino

  static char*msg = str_out.c_str();  // store it as msg

  rf_driver.send((uint8_t*)msg,strlen(msg)); // function to send data
  rf_driver.waitPacketSent();
  delay(1000);
 
  Serial.print("\n \r X:"); //Print the Values on Serial Monitor
  Serial.print(String(ax));
  Serial.print("\n \r Y:");
  Serial.print(String(ay));
}

Receiver.ino

Arduino
Code for the Receiver Part
#include <RH_ASK.h>
#include <SPI.h> //Serial peripheral interface library


RH_ASK rf_driver;

String accel;
String gyro;
String str_out;

int ax, ay; // create the variables for storing int values of string(accel) and string(gyro)

 int M1 =3;
 int M2 =4;
 int M3 =5;
 int M4 =6;
int ENA = 9;  //PWM pins of arduino pro mini or most of the Arduino
int ENB = 10;

void setup() 
{
  rf_driver.init();
  Serial.begin(9600);
  pinMode(M1, OUTPUT);
  pinMode(M2, OUTPUT);
  pinMode(M3, OUTPUT);
  pinMode(M4, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);

}

void loop() 
{
  uint8_t buf[7];  // mention the size of the data... depends on how much data is sent. In this case [7].
  uint8_t buflen = sizeof(buf); // store the whole data ...depends on the user .. if you want you can store  specific part of data.
  if(rf_driver.recv(buf, &buflen))
   {
    str_out = String((char*)buf); //Again recover and seperate the values which were combined in the transmitter program.
    
      for(int i=0; i<str_out.length(); i++)
      {
        if(str_out.substring(i,i+1)==",")
          {
            accel =str_out.substring(0,i);  // create seperate substrings to store the values of accel and gyro
            gyro =str_out.substring(i+1);
            break;
          }
    Serial.print("X:");  //Print the values
    Serial.println(accel);
    Serial.print("Y:");
    Serial.println(gyro);
      
      }
   }

    ax= accel.toInt(); //Convert the Received string values to Int values.
    ay= gyro.toInt();
    
     if(( ax > 520 && ax<550 && ay>130 &&ay<160 )) // Create setpoints ....depends on MPU to MPU you have to set these manually ..dont copy the values may wont work in your case.
     {
      analogWrite(ENA, 255); //Forward
      analogWrite(ENB, 255);
      digitalWrite(M1, HIGH);
      digitalWrite(M2, LOW);
      digitalWrite(M3, HIGH);
      digitalWrite(M4, LOW);
     }
     else if(ax >545 && ax<570 && ay>100 && ay< 120)
     {
      analogWrite(ENA, 255 ); //Backward
      analogWrite(ENB, 255 );
      digitalWrite(M1, LOW);
      digitalWrite(M2, HIGH);
      digitalWrite(M3, LOW);
      digitalWrite(M4, HIGH);
     }
     else if(ay<40 && ay>7 &&ax>490 && ax<520) 
      {
       analogWrite(ENA,255); //Right
      analogWrite(ENB, 255);
      digitalWrite(M1, LOW);
      digitalWrite(M2, HIGH);
      digitalWrite(M3, HIGH);
      digitalWrite(M4, LOW);
      }
     else if( ay>250 && ay<265 &&ax>510 &&ax<540)
      {
       analogWrite(ENA, 255); //Left
      analogWrite(ENB, 255);
      digitalWrite(M1, HIGH);
      digitalWrite(M2, LOW);
      digitalWrite(M3, LOW);
      digitalWrite(M4, HIGH);
      }

     else 
     {
      analogWrite(ENA, 0);
      analogWrite(ENB, 0);
     }
}  

Credits

Varun walimbe
15 projects • 69 followers
I like to innovate and make different types of Robots and systems that thrive to make human lives easier :)
Contact

Comments

Please log in or sign up to comment.