Projects / Hand gesture controlled robot

Hand gesture controlled robot

Intermediate3 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOMPU6050tilt 27°

    Read the MPU6050

    Print the two axes.

  2. NANO

    Choose the tilt limits

    Dead zone around level.

  3. NANO

    Send a letter

    Over nRF24.

  4. NANOROBOT

    Build the car

    Chassis, motors, L298N.

  5. NANO

    Receive and drive

    Wheels off the ground first.

  6. NANO

    Add the 500 ms stop

    Unplug the glove to test.

  7. NANO

    Drive on the floor

    In an open space.

In short

How do you build a hand gesture controlled robot?

Tilt your hand with an MPU6050 glove and an nRF24 link drives a robot car in the direction you tilt. You need Arduino Nano × 2, MPU6050 IMU, nRF24L01+ Radio Module × 2, Electrolytic capacitor 10 µF × 2, L298N Dual H-Bridge Module, Robot car chassis kit 2WD (acrylic), Battery holder 18650 2S (series) and 18650 cell 2600 mAh (branded) × 2. It takes 7 steps and about 180 minutes.

Level
Intermediate
Time
About 180 min
Parts
8

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Glove: MPU6050 SDA and SCLNano A4 and A5I2C
Glove: MPU6050 VCC and GNDNano 3V3 or 5V (per module) and GNDPower
Both: nRF24 CE and CSNNano D7 and D8Radio control
Both: nRF24 SCK, MOSI, MISONano D13, D11, D12SPI
Both: nRF24 VCC and GNDNano 3V3 and GND, with 10 uF across themPower (never 5 V)
Car: L298N IN1, IN2, IN3, IN4Nano D2, D3, D4, D9Directions
Car: L298N ENA and ENBNano D5 and D6Speed (remove the jumpers)
Car: L298N OUT1 and OUT2, OUT3 and OUT4Left motors and right motorsMotor drive
Car: 2 x 18650 holderL298N 12V and Nano VINAbout 7.4 V
Glove powerUSB power bank in a pocketPower for the glove Nano

Code

Tilting a sensor changes how gravity pulls on each of its axes, so the accelerometer inside the MPU6050 can tell which way your hand is leaning. The glove sketch turns that into one letter: forward, back, left, right or stop, with a dead zone so a level hand means stop. It sends the letter twenty times a second over the nRF24 radio link, and the car stops by itself if it does not hear anything for half a second, so losing the signal or taking the glove off stops it. The radios need a clean 3.3 V and a 10 uF capacitor across their power pins, otherwise they drop packets. Start with the wheels off the ground and test each direction, then try it on the floor in an open space with no stairs. Keep fingers away from the wheels, and use the 18650 cells in a proper holder; keep them away from anything that could short them. The glove sketch is the first half of the file, the car sketch is in the comment, so uncomment it for the second Nano. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Gesture robot: two sketches in one file. Libraries: RF24. Board: Arduino Nano. Use the glove half on one Nano, the car half on the other.
// ---------- GLOVE (transmitter) ----------
#include <Wire.h>
#include <SPI.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte ADDR[6] = "ROBO1";
int16_t readAxis(byte reg) { Wire.beginTransmission(0x68); Wire.write(reg); Wire.endTransmission(false); Wire.requestFrom(0x68, 2); return (Wire.read() << 8) | Wire.read(); }
void setup() {
  Wire.begin();
  Wire.beginTransmission(0x68); Wire.write(0x6B); Wire.write(0); Wire.endTransmission();     // wake the MPU6050
  radio.begin(); radio.setPALevel(RF24_PA_LOW); radio.openWritingPipe(ADDR); radio.stopListening();
}
void loop() {
  float ax = readAxis(0x3B) / 16384.0, ay = readAxis(0x3D) / 16384.0;    // acceleration in g
  char cmd = 'S';
  if (ax > 0.45) cmd = 'F'; else if (ax < -0.45) cmd = 'B';              // tilt forward or back
  else if (ay > 0.45) cmd = 'R'; else if (ay < -0.45) cmd = 'L';         // tilt right or left
  radio.write(&cmd, 1);
  delay(50);
}
/* ---------- CAR (receiver): upload this half to the other Nano ----------
#include <SPI.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte ADDR[6] = "ROBO1";
const byte IN1 = 2, IN2 = 3, IN3 = 4, IN4 = 9, ENA = 5, ENB = 6;
unsigned long lastCmd = 0;
void drive(int l, int r) {                         // -255 to 255 for each side
  digitalWrite(IN1, l > 0); digitalWrite(IN2, l < 0); analogWrite(ENA, abs(l));
  digitalWrite(IN3, r > 0); digitalWrite(IN4, r < 0); analogWrite(ENB, abs(r));
}
void setup() {
  for (byte p = 2; p <= 9; p++) pinMode(p, OUTPUT);
  radio.begin(); radio.setPALevel(RF24_PA_LOW); radio.openReadingPipe(1, ADDR); radio.startListening();
}
void loop() {
  if (radio.available()) {
    char c; radio.read(&c, 1); lastCmd = millis();
    if (c == 'F') drive(170, 170); else if (c == 'B') drive(-170, -170);
    else if (c == 'L') drive(-150, 150); else if (c == 'R') drive(150, -150);
    else drive(0, 0);
  }
  if (millis() - lastCmd > 500) drive(0, 0);        // stop if no command for half a second
}
*/

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Hand levelCar stops
Tilt forwardCar drives forward
Tilt left or rightCar turns on the spot
Glove switched offCar stops within half a second

If it does not work

No radio link

Check the 10 uF capacitors and the address.

Wrong direction

Swap the motor wires or the tilt signs.

Jerky

Lower the send rate or the dead zone.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the hand gesture controlled robot?

Arduino Nano × 2, MPU6050 IMU, nRF24L01+ Radio Module × 2, Electrolytic capacitor 10 µF × 2, L298N Dual H-Bridge Module, Robot car chassis kit 2WD (acrylic), Battery holder 18650 2S (series) and 18650 cell 2600 mAh (branded) × 2.

How long does the hand gesture controlled robot take to build?

About 180 minutes for a intermediate maker, in 7 steps.

How do I know the hand gesture controlled robot works?

Hand level: Car stops. Tilt forward: Car drives forward. Tilt left or right: Car turns on the spot.

No radio link: what should I check?

Check the 10 uF capacitors and the address.

Wrong direction: what should I check?

Swap the motor wires or the tilt signs.

Jerky: what should I check?

Lower the send rate or the dead zone.