Projects / Glove-controlled toy car

Glove-controlled toy car

Intermediate4 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOMPU6050tilt 19°

    Test the IMU

    Print forward and sideways tilt.

  2. NANONRF24L01

    Test the radios

    Send a number between the two Nanos.

  3. NANOROBOT

    Build the car

    Mount motors and driver, check each wheel direction.

  4. NANO

    Mix the speeds

    Forward plus or minus the turn.

  5. NANO

    Add the dead zone

    Flat hand means stop.

  6. NANO

    Add the fail-safe

    Stop after 300 ms without data.

  7. NANOMPU6050tilt 19°

    Sew the glove

    Fix the IMU on the back of the hand.

In short

How do you build a glove-controlled toy car?

Tilt your hand in a glove to drive a toy car over nRF24 radio. You need Arduino Nano × 2, MPU6050 IMU, nRF24L01+ Radio Module × 2, Robot car chassis kit 2WD (acrylic), L298N Dual H-Bridge Module, Battery holder 4 × AA with switch, AA alkaline battery × 4 and Electrolytic capacitor 10 µF × 2. It takes 7 steps and about 240 minutes.

Level
Intermediate
Time
About 240 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 VCC and GNDNano 3V3 and GNDPower
MPU6050 SDA and SCLNano A4 and A5I2C
nRF24 VCC and GNDNano 3V3 and GNDPower (add 10 µF across)
nRF24 CE, CSNNano D9, D10Control
nRF24 SCK, MOSI, MISONano D13, D11, D12SPI
CAR: nRF24 power, CE, CSN, SPISame as the gloveRadio (10 µF across the supply)
L298N ENA and ENBNano D5 and D6Left and right speed (PWM)
L298N IN1, IN2, IN3, IN4Nano D2, D3, D4, D7Direction
L298N 12V terminal4 AA pack plus (6 V)Motor power
L298N 5V outputNano 5VLogic power (remove the 5 V jumper only if supplying more than 12 V)
L298N GNDNano GND and battery minusCommon ground

Code

The glove sends two numbers, forward tilt and sideways tilt, about 30 times a second. The car mixes them into left and right motor speeds, so tilting forward drives, and tilting sideways turns. A dead zone makes a flat hand stop the car, and if no radio message arrives for 0.3 seconds the car stops by itself. The top speed is limited to keep the toy controllable. Test with the wheels lifted off the ground first. The nRF24 modules run on 3.3 V and need a 10 µF capacitor across their supply or they drop packets. Radio has no security, so another glove on the same address would take over: choose your own address, and use it only as a toy. Keep the car away from roads, stairs and small children and pets. Use fresh alkaline cells; do not mix old and new. 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).

// GLOVE unit. Libraries: Adafruit MPU6050, RF24. Board: Arduino Nano.
#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <SPI.h>
#include <RF24.h>
Adafruit_MPU6050 mpu; RF24 radio(9, 10);
const byte ADDR[6] = "GLOVE";
struct Cmd { int8_t pitch; int8_t roll; } cmd;

void setup() {
  mpu.begin();
  radio.begin(); radio.setPALevel(RF24_PA_LOW); radio.openWritingPipe(ADDR); radio.stopListening();
}

void loop() {
  sensors_event_t a, g, t; mpu.getEvent(&a, &g, &t);
  float pitch = constrain(a.acceleration.x / 9.81 * 100, -100, 100);   // tilt forward or back
  float roll  = constrain(a.acceleration.y / 9.81 * 100, -100, 100);   // tilt left or right
  cmd.pitch = abs(pitch) < 25 ? 0 : pitch;                             // dead zone: a flat hand stops the car
  cmd.roll  = abs(roll)  < 25 ? 0 : roll;
  radio.write(&cmd, sizeof(cmd));
  delay(30);
}

/* ---- CAR unit. Libraries: RF24. Board: Arduino Nano.
#include <SPI.h>
#include <RF24.h>
RF24 radio(9, 10);
const byte ADDR[6] = "GLOVE";
struct Cmd { int8_t pitch; int8_t roll; } cmd;
const int ENA = 5, ENB = 6, IN1 = 2, IN2 = 3, IN3 = 4, IN4 = 7;
unsigned long lastRx = 0;
const int MAXSPD = 200;                       // limit the top speed

void drive(int left, int right) {              // -255 to 255 each
  digitalWrite(IN1, left > 0);  digitalWrite(IN2, left < 0);
  digitalWrite(IN3, right > 0); digitalWrite(IN4, right < 0);
  analogWrite(ENA, min(abs(left), MAXSPD)); analogWrite(ENB, min(abs(right), MAXSPD));
}

void setup() {
  for (int p : {ENA, ENB, IN1, IN2, IN3, IN4}) pinMode(p, OUTPUT);
  radio.begin(); radio.setPALevel(RF24_PA_LOW); radio.openReadingPipe(1, ADDR); radio.startListening();
}

void loop() {
  if (radio.available()) { radio.read(&cmd, sizeof(cmd)); lastRx = millis(); }
  if (millis() - lastRx > 300) { drive(0, 0); return; }            // fail safe: stop if the signal is lost
  int speed = map(cmd.pitch, -100, 100, -255, 255);
  int turn  = map(cmd.roll, -100, 100, -150, 150);
  drive(constrain(speed + turn, -255, 255), constrain(speed - turn, -255, 255));
}
*/

Test checklist

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

CheckExpected
Hand flatCar stops
Tilt forwardCar drives forward
Tilt left or rightCar turns
Switch the glove offCar stops within a third of a second

If it does not work

Motors run the wrong way

Swap the motor wires.

No radio

Add the 10 µF capacitor and check CE and CSN.

Car creeps

Widen the dead zone.

Glove reading drifts

Keep the IMU fixed flat on the hand.

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

Ask Lark AI

Common questions

What parts do I need for the glove-controlled toy car?

Arduino Nano × 2, MPU6050 IMU, nRF24L01+ Radio Module × 2, Robot car chassis kit 2WD (acrylic), L298N Dual H-Bridge Module, Battery holder 4 × AA with switch, AA alkaline battery × 4 and Electrolytic capacitor 10 µF × 2.

How long does the glove-controlled toy car take to build?

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

How do I know the glove-controlled toy car works?

Hand flat: Car stops. Tilt forward: Car drives forward. Tilt left or right: Car turns.

Motors run the wrong way: what should I check?

Swap the motor wires.

No radio: what should I check?

Add the 10 µF capacitor and check CE and CSN.

Car creeps: what should I check?

Widen the dead zone.

Glove reading drifts: what should I check?

Keep the IMU fixed flat on the hand.