Summary
Gesture-controlled robots make robotics feel much more interactive because the robot responds to physical movement instead of a joystick, buttons, or smartphone commands. The basic idea is surprisingly approachable: an IMU detects how the hand is tilted, Arduino interprets that movement, and a motor driver translates it into movement from the robot's motors.
This guide explains how to build a gesture controlled robot Arduino project using an Arduino Uno, MPU6050 motion sensor, L298N motor driver, DC geared motors, and a robot chassis.

What You Need
- Arduino Uno – Processes the gesture data and controls the motors
- MPU6050 6-axis IMU sensor – Detects acceleration and angular movement
- L298N motor driver – Controls motor direction and speed
- DC geared motors – Drive the robot's wheels
- Robot chassis with wheels – Provides the mechanical structure
- 9V–12V battery pack – Powers the robot
- Jumper wires – Connect the modules
These are the core components specified in the original project.
Components and Supplies
Parts Required
| Component | Purpose |
|---|---|
| Arduino Uno | Processes sensor data and controls the robot |
| MPU6050 | Detects hand tilt and movement |
| L298N Motor Driver | Controls motor direction and speed |
| DC Geared Motors | Move the robot |
| Robot Chassis | Holds the motors and electronics |
| 9V–12V Battery Pack | Provides project power |
| Jumper Wires | Connects the components |
How Does a Gesture-Controlled Robot Work?
The MPU6050 continuously measures movement and orientation. Arduino reads this information and converts the detected tilt into a movement command.
The basic control logic is:
Hand movement → MPU6050 → Arduino → L298N → DC motors → Robot movement
For this project:
| Hand Gesture | Robot Action |
|---|---|
| Tilt forward | Move forward |
| Tilt backward | Move backward |
| Tilt left | Turn left |
| Tilt right | Turn right |
| Keep sensor near level | Stop |
The original project uses tilt thresholds of approximately ±20 degrees to distinguish between these movements.

How to Build the Gesture-Controlled Robot
Step 1: Assemble the Chassis
Mount the two DC geared motors onto the robot chassis and attach the wheels.
Make sure:
- Both motors are firmly secured
- Wheels rotate freely
- Motor shafts are properly aligned
- The chassis sits evenly on a flat surface
A loose motor mount can introduce vibration and make the robot's movement inconsistent.
Step 2: Connect the L298N Motor Driver
Mount the L298N near the motors to keep the motor wiring short and organized.
Connect the motors to the driver:
- Motor A → OUT1 and OUT2
- Motor B → OUT3 and OUT4
If a motor rotates in the opposite direction from what the program expects, swapping its two motor wires reverses its direction.
Step 3: Connect the Motor Control Pins
The Arduino controls motor speed using the L298N's enable pins and PWM.
Connect:
| L298N Pin | Arduino |
|---|---|
| ENA | D5 |
| IN1 | D2 |
| IN2 | D3 |
| ENB | D6 |
| IN3 | D4 |
| IN4 | D7 |
The ENA and ENB pins control motor speed, while IN1–IN4 determine the direction of each motor.
Step 4: Connect the MPU6050
The MPU6050 communicates with Arduino using I2C.
Connect:
| MPU6050 | Arduino Uno |
|---|---|
| VCC | 5V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
The SDA and SCL connections are particularly important because the Arduino communicates with the sensor through these two I2C lines.
Step 5: Connect the Power Supply
The original project uses a 9V–12V battery pack.
Connect the battery to:
- Positive → Arduino VIN
- Negative → Arduino GND
The L298N motor driver also receives the battery supply through its power input.
Before switching on the system, check the polarity and make sure no exposed wires can touch each other

How to Program the Robot
The code has three jobs: read the MPU6050, convert the sensor data into tilt angles, and use those angles to control the motors. A simple threshold-based approach is enough for the first version of the robot. If the hand tilts beyond a set angle, Arduino interprets it as a movement command. If the sensor remains roughly level, the robot stops.
Install the MPU6050 and I2Cdev libraries in the Arduino IDE before uploading the following complete sketch.
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
MPU6050 mpu;
// L298N motor driver pins
const int ENA = 5;
const int IN1 = 2;
const int IN2 = 3;
const int ENB = 6;
const int IN3 = 4;
const int IN4 = 7;
int16_t ax, ay, az;
void setup() {
Serial.begin(9600);
Wire.begin();
mpu.initialize();
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
stopMotors();
if (!mpu.testConnection()) {
Serial.println("MPU6050 connection failed!");
while (1);
}
Serial.println("Gesture Robot Ready");
}
void loop() {
// Read acceleration from MPU6050
mpu.getAcceleration(&ax, &ay, &az);
// Calculate approximate tilt angles
float angleX = atan2(ay, az) * 180.0 / PI;
float angleY = atan2(ax, az) * 180.0 / PI;
Serial.print("X: ");
Serial.print(angleX);
Serial.print(" Y: ");
Serial.println(angleY);
// Gesture detection
if (angleX > 20) {
moveBackward();
}
else if (angleX < -20) {
moveForward();
}
else if (angleY > 20) {
turnRight();
}
else if (angleY < -20) {
turnLeft();
}
else {
stopMotors();
}
delay(100);
}
// ---------------- Motor Functions ----------------
void moveForward() {
analogWrite(ENA, 180);
analogWrite(ENB, 180);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void moveBackward() {
analogWrite(ENA, 180);
analogWrite(ENB, 180);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
void turnLeft() {
analogWrite(ENA, 180);
analogWrite(ENB, 180);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void turnRight() {
analogWrite(ENA, 180);
analogWrite(ENB, 180);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
void stopMotors() {
analogWrite(ENA, 0);
analogWrite(ENB, 0);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
Understanding the Gesture Logic
The MPU6050 measures acceleration along three axes. When the sensor is tilted, the acceleration values change relative to each other. The code converts these readings into approximate X and Y tilt angles.
The important part is the threshold:
if (angleX > 20)
A tilt greater than roughly 20° is treated as one gesture, while less than -20° represents the opposite direction. Small movements between -20° and +20° are treated as neutral, so the robot stops instead of reacting to every tiny movement.
The resulting logic is:
Tilt forward → Forward
Tilt backward → Backward
Tilt left → Left
Tilt right → Right
Sensor roughly level → Stop
The moveForward(), moveBackward(), turnLeft(), and turnRight() functions simply set the L298N's direction pins appropriately. analogWrite() controls the motor speed through the driver's ENA and ENB pins.
If the robot moves in the opposite direction from the intended gesture, the motor wires or the corresponding direction logic can be reversed. Similarly, if the gesture directions feel inverted, check the MPU6050's physical orientation and adjust the angle conditions accordingly.
How to Test the Robot
Place the robot on a smooth, flat surface before testing.
- Power on the robot.
- Allow the MPU6050 to stabilize.
- Keep the sensor approximately level and confirm the motors remain stopped.
- Tilt forward and check the forward movement.
- Tilt backward and check the reverse movement.
- Tilt left and right to test turning.
If the robot moves in the wrong direction, check the motor wiring and sensor orientation before changing the code. The original project also recommends checking the battery, MPU6050 connections, L298N wiring, and sensor threshold values when movement is inconsistent.
Common Problems and Fixes
| Problem | What to Check |
|---|---|
| Robot doesn't move | Battery, L298N power and motor wiring |
| MPU6050 not detected | VCC, GND, SDA, SCL and libraries |
| Robot moves backward instead of forward | Motor polarity or gesture logic |
| Robot turns incorrectly | Motor wiring and sensor orientation |
| Movement is jerky | Battery, motor connections and threshold values |
Testing one subsystem at a time makes debugging much easier.
Explore More Arduino-Based Projects
The same Arduino and motor-control concepts can be applied to other robotics projects. For another project using wireless commands and motors, see our blog on how to Build a Bluetooth Controlled Car.
The broader idea of using a controller to interpret an input and trigger an output also appears in home automation. Our I Built a Voice Controlled Home Automation System explores the same input-processing-output approach using voice commands, Bluetooth, Arduino, and relays.
Final Thoughts
A gesture controlled robot Arduino project combines three fundamental robotics concepts: sensing, decision-making, and motor control. The MPU6050 detects hand movement, Arduino interprets the sensor data, and the L298N drives the motors according to the resulting command.
The project is relatively simple to build, but it introduces useful concepts such as I2C communication, PWM motor control, sensor thresholds, power management, and systematic troubleshooting. Once the basic robot works, the same architecture can be extended with smoother motion control, additional gestures, variable speed, or more advanced sensors.





