Build it step by step
0 of 7 doneTest the IMU
Print forward and sideways tilt.
Test the radios
Send a number between the two Nanos.
Build the car
Mount motors and driver, check each wheel direction.
Mix the speeds
Forward plus or minus the turn.
Add the dead zone
Flat hand means stop.
Add the fail-safe
Stop after 300 ms without data.
Sew the glove
Fix the IMU on the back of the hand.
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
- Development BoardsBuyArduino Nano × 2
- SensorsBuyMPU6050 IMU × 1
- WirelessBuy
- Mechanical & HardwareBuy
- Motor DriversBuy
- PowerBuy
- BatteriesBuy
- PassivesBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| GLOVE: MPU6050 VCC and GND | Nano 3V3 and GND | Power |
| MPU6050 SDA and SCL | Nano A4 and A5 | I2C |
| nRF24 VCC and GND | Nano 3V3 and GND | Power (add 10 µF across) |
| nRF24 CE, CSN | Nano D9, D10 | Control |
| nRF24 SCK, MOSI, MISO | Nano D13, D11, D12 | SPI |
| CAR: nRF24 power, CE, CSN, SPI | Same as the glove | Radio (10 µF across the supply) |
| L298N ENA and ENB | Nano D5 and D6 | Left and right speed (PWM) |
| L298N IN1, IN2, IN3, IN4 | Nano D2, D3, D4, D7 | Direction |
| L298N 12V terminal | 4 AA pack plus (6 V) | Motor power |
| L298N 5V output | Nano 5V | Logic power (remove the 5 V jumper only if supplying more than 12 V) |
| L298N GND | Nano GND and battery minus | Common 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.
| Check | Expected |
|---|---|
| Hand flat | Car stops |
| Tilt forward | Car drives forward |
| Tilt left or right | Car turns |
| Switch the glove off | Car 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 →
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.
