Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

Gesture Controlled Robot Using Arduino: Parts and Code

Gesture Controlled Robot Using Arduino: Parts and Code
-
Written By - Robocraze -
📅 Updated on 24 Aug 2026
Summarize with AI
✅ Prompt copied

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.

I Built a Gesture Controlled Robot Using These Parts - Cover Image

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

Jumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - RobocrazeJumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - Robocraze

    Jumper Wire Set - M2M, M2F, F2F (40 pcs each)

    Jumper Wire Set - M2M, M2F, F2F (40 pcs each) These DuPont jumper wires for electronics is a premium quality wire manufactured by using quality assured material and advanced techniques, which make them up to the standard in this highly challenging field. This 120pcs...
    Rs 139/-
    Rs 139/-
    Rs 169/-
    Save Rs 30/-
    Dual L298N Motor Driver Module with PWM Control – Powerful motor driver for robotic applications – RobocrazeDual L298N Motor Driver Module with PWM Control – Powerful motor driver for robotic applications – Robocraze

      2A Dual L298N Motor Driver Module with PWM Control

      2A Dual L298N Motor Driver Module with PWM Control The L298N Motor Driver Module is a great choice for controlling motors! It contains a double H bridge L298N chip, which has a maximum voltage of 46V and a current of 2A. This L298N dual...
      Rs 149/-
      Rs 149/-
      Rs 179/-
      Save Rs 30/-
      SmartElex L298N Dual Channel Motor Driver with Onboard Arduino Uno -RobocrazeSmartElex L298N Dual Channel Motor Driver with Onboard Arduino Uno -Robocraze

      SmartElex L298N Dual Channel Motor Driver with Onboard Arduino Uno

      SmartElex L298N Dual Channel Motor Driver with Onboard Arduino Uno The SmartElex L298N Motor Driver with Onboard Arduino Uno is an all-in-one motor control solution designed for robotics and mechatronics enthusiasts. It combines the power of the L298N dual-channel motor driver with the versatility...
      Rs 979/-
      Rs 979/-
      Rs 1,499/-
      Save Rs 520/-
      Original Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -RobocrazeOriginal Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -Robocraze

      Arduino Uno R3 Original

      Arduino UNO R3 Original The Arduino Uno R3 is a microcontroller board based on the ATmega328P chip and is widely recognized as the best original Arduino Uno board for beginners and projects. This board has 14 digital I/O pins (6 support PWM), 6 analog...
      Rs 2,619/-
      Rs 2,619/-
      Rs 2,999/-
      Save Rs 380/-
      Arduino UNO Sensor Shield V5 – Upgraded Arduino shields with better sensor connectivity. -RobocrazeArduino UNO Sensor Shield V5 – Upgraded Arduino shields with better sensor connectivity. -Robocraze

        Arduino UNO Sensor Shield Expansion board V5

        UNO Sensor Shield for Arduino Expansion board V5 This sensor shield for UNO board compatible with Arduino is the latest shield V5 model. This sensor shield allows you to connect to various modules like sensors, servos, relays, buttons, potentiometers and many more directly to your Arduino through...
        Rs 92/-
        Rs 92/-
        Rs 129/-
        Save Rs 37/-
        Arduino Nano R3 Dev Board – Small compatible Arduino Board with USB and ATmega328P for beginners and makers. -RobocrazeArduino Nano R3 Dev Board – Small compatible Arduino Board with USB and ATmega328P for beginners and makers. -Robocraze

          Arduino Nano R3 Development Board Compatible

          Arduino Nano R3 Development Board Compatible with Arduino The CH340 Soldered Arduino Nano Board R3 chipboard is based on the famous Arduino platform and does all the functions of Uno but with a smaller footprint, making it a best Arduino Nano board for electronics prototyping...
          Rs 209/-
          Rs 209/-
          Rs 299/-
          Save Rs 90/-

          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.

          Project

          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

           

          Project

          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.

          1. Power on the robot.
          2. Allow the MPU6050 to stabilize.
          3. Keep the sensor approximately level and confirm the motors remain stopped.
          4. Tilt forward and check the forward movement.
          5. Tilt backward and check the reverse movement.
          6. 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.

          Excerpt

          Build a robot that responds to hand gestures using Arduino and an accelerometer module. Full parts list, wiring and code for your own gesture-controlled build.
          Prev Post
          Next Post

          Leave a comment

          Please note, comments need to be approved before they are published.

          Thanks for subscribing!

          This email has been registered!

          Shop the look

          Choose Options

          Edit Option
          Back In Stock Notification
          Compare
          Product SKU Description Collection Availability Product Type Other Details

          Choose Options

          this is just a warning
          Login
          Shopping Cart
          0 items
          FREE SHIPPING!
          ₹100 OFF
          ₹200 OFF
          ₹999
          ₹2500
          ₹4900
          WhatsApp Chat Chat