Introduction: Gesture Controlled Wireless Car
In this tutorial we are going to learn, how to make a gesture controlled car or any robot. This project has two part, one part is transmitter unit and other part is receiver unit. Transmitter unit is actually mounted on a hand gloves and receiver unit is placed inside a car or any robot. Now its time to make a nice car. Lets go!
Step 1: Equipments
Transmitter Unit
1. Arduino Nano.
2. MPU6050 Sensor Module.
3. RF 433 MHz Transmitter.
4. Any type of 3 cell, 11.1 volt Battery (Here I've used coin cell).
5. Vero-Board.
6. Hand Gloves.
Receiver Unit
1. Arduino Nano or Arduino Uno.
2. L298N Motor Driver Module.
3. 4 wheel robot frame including motors.
4. RF 433 RF Receiver.
5. 3 cell, 11.1 volt Li-po Battery.
6. Vero-board.
Others
1. Glue Sticks and gun.
2. Jumper wires.
3. Screw Drivers
4. Soldering Kit.
etc.
Step 2: Circuit Diagram Image File
Step 3: Fritzing File of Circuit Diagram
Attachments
Step 4: Transmitter Code
#include <VirtualWire.h>
#include <MPU6050_tockn.h>
#include <Wire.h>
MPU6050 mpu6050(Wire);
long timer = 0; char *controller;
void setup() { Serial.begin(9600); Wire.begin(); mpu6050.begin(); mpu6050.calcGyroOffsets(true); vw_set_ptt_inverted(true); // vw_set_tx_pin(10); vw_setup(4000);// speed of data transfer Kbps
}
void loop() { ////////////////////////////////////////////////////////////////////////////////////////////////
mpu6050.update();
if(millis() - timer > 1000) { Serial.println("======================================================="); Serial.print("temp : ");Serial.println(mpu6050.getTemp()); Serial.print("accX : ");Serial.print(mpu6050.getAccX()); Serial.print("\taccY : ");Serial.print(mpu6050.getAccY()); Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ()); Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX()); Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY()); Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ()); Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX()); Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY()); Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX()); Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY()); Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ()); Serial.print("angleX : ");Serial.print(mpu6050.getAngleX()); Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY()); Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ()); Serial.println("=======================================================\n"); timer = millis(); }
///////////////////////////////////////////////////////////////////////////////////// if (mpu6050.getAccAngleX()<-25) { controller="X1" ; vw_send((uint8_t *)controller, strlen(controller)); vw_wait_tx(); // Wait until the whole message is gone Serial.println("BACKWARD"); } else if (mpu6050.getAccAngleX()>30) { controller="X2" ; vw_send((uint8_t *)controller, strlen(controller)); vw_wait_tx(); // Wait until the whole message is gone Serial.println("FORWARD"); } else if (mpu6050.getAccAngleY()>40 ) { controller="Y1" ; vw_send((uint8_t *)controller, strlen(controller)); vw_wait_tx(); // Wait until the whole message is gone Serial.println("LEFT"); } else if (mpu6050.getAccAngleY()<-40) { controller="Y2" ; vw_send((uint8_t *)controller, strlen(controller)); vw_wait_tx(); // Wait until the whole message is gone Serial.println("RIGHT"); } else if (mpu6050.getAccAngleX()<10 && mpu6050.getAccAngleX()>-10 && mpu6050.getAccAngleY()<10 && mpu6050.getAccAngleY()>-10) { controller="A1" ; vw_send((uint8_t *)controller, strlen(controller)); vw_wait_tx(); // Wait until the whole message is gone Serial.println("STOP"); } }
Step 5: Receiver Code
#include <VirtualWire.h>
int LA = 3; int LB = 11; int RA = 5; int RB = 6; void setup() { Serial.begin(9600); vw_set_ptt_inverted(true); // Required for DR3100 vw_set_rx_pin(12); vw_setup(4000); // Bits per sec pinMode(13, OUTPUT); pinMode(LA, OUTPUT); pinMode(LB, OUTPUT); pinMode(RA, OUTPUT); pinMode(RB, OUTPUT); vw_rx_start(); // Start the receiver PLL running Serial.println("All OK");
} void loop() { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking { if((buf[0]=='X')&&(buf[1]=='1')) { Serial.println("BACKWARD"); backward(); delay(100); //off(); } else if((buf[0]=='X')&&(buf[1]=='2')) { Serial.println("FORWARD"); forward(); delay(100); //off(); }
else if((buf[0]=='Y')&&(buf[1]=='1')) { Serial.println("LEFT"); left(); delay(100); //off(); }
else if((buf[0]=='Y')&&(buf[1]=='2')) { Serial.println("RIGHT"); right(); delay(100); //off(); } else if((buf[0]=='A')&&(buf[1]=='1')) { Serial.println("STOP"); off(); delay(100); } } else { Serial.println("No Signal Received"); } }
void forward() { analogWrite(LA, 70); analogWrite(LB, 0); analogWrite(RA, 70); analogWrite(RB, 0); }
void backward() { analogWrite(LA, 0); analogWrite(LB, 70); analogWrite(RA, 0); analogWrite(RB, 70); }
void left() { analogWrite(LA, 0); analogWrite(LB, 70); analogWrite(RA, 70); analogWrite(RB, 0); }
void right() { analogWrite(LA, 70); analogWrite(LB, 0); analogWrite(RA, 0); analogWrite(RB, 70); }
void off() { analogWrite(LA, 0); analogWrite(LB, 0); analogWrite(RA, 0); analogWrite(RB, 0); }
Step 6: INO Files
Step 7: Link of Libraries
Virtual Wire Library: https://www.resistorpark.com/content/Arduino_Libra...
MPU6050_tockn Libraby: https://github.com/tockn/MPU6050_tockn/archive/mas...
Wire Library: https://www.resistorpark.com/content/Arduino_Libra...