Arduino Maker Series Under 1000: Gesture Controlled Wireless Car

Arduino Maker Series Under 1000: Gesture Controlled Wireless Car

Welcome to the Arduino Maker Series Under 1000! This is the second project in the series. Today, we will build a gesture-controlled wireless car using MPU6050 sensor, and Wemos D1 boards. This project is a fun, interactive, and educational way to explore IoT, electronics, and wireless communication. By the end, your car will respond to your hand gestures to move forward, backward, left, and right, demonstrating real-time control and sensor integration.You can use any wifi boards, like Esp8266 or wemos d1 mini, which has the ESP chip.

Table of Contents

  • Introduction
  • Required Hardware
  • Arduino IDE Setup
  • Wiring the Components
  • Understanding the MPU6050 Sensor
  • Remote Arduino Code
  • Tank Arduino Code
  • How It Works
  • Testing Your Project
  • Advanced Modifications
  • Common Issues and Troubleshooting
  • Learning Insights for Beginners
  • Conclusion

1. Introduction

This project allows you to control a small car wirelessly using hand gestures. The MPU6050 accelerometer and gyroscope detects tilt and orientation of your hand. The remote Wemos D1 board reads this data and sends control signals via UDP Wi-Fi to the car. The tank Wemos D1 interprets these commands and drives the motors accordingly. This project is ideal for:

  • Beginners learning Arduino and electronics
  • Makers exploring wireless control systems
  • Students learning IoT and sensor integration
  • Anyone looking to build interactive robotic projects under budget

2. Required Hardware

  • 2 × Wemos D1 R1 (ESP8266) – ~₹700 each
  • 1 × MPU6050 Module – ₹200
  • L298N Motor Driver – ₹250
  • 2 × DC Motors with wheels and chassis – ₹500
  • Battery pack 7.4V Li-ion – ₹400
  • Jumper Wires & Breadboard – ₹100
  • Arduino IDE installed on your PC
  • Optional: USB power supply for testing remote module

3. Arduino IDE Setup

Follow these steps to set up your Arduino IDE:

  1. Download and install the latest Arduino IDE.
  2. Connect Wemos D1 boards via USB to your PC.
  3. Select the correct board under Tools > Board > Wemos D1 R1.
  4. Select the correct COM port under Tools > Port.
  5. Install required libraries using Library Manager:
    • Wire.h – for I2C communication
    • MPU6050.h – for MPU6050 sensor interface
    • ESP8266WiFi.h – for Wi-Fi communication
    • WiFiUdp.h – for sending UDP packets
  6. Verify the IDE can compile for the Wemos D1 boards before proceeding.

4. Wiring the Components

Wiring correctly is crucial for reliable operation. Follow the wiring diagram carefully:

Remote Side (Hand Gesture Module)

  • MPU6050 VCC → 3.3V on Wemos D1
  • MPU6050 GND → GND
  • MPU6050 SDA → D2
  • MPU6050 SCL → D1

Tank Side (Car Module)

  • D5 → IN1
  • D6 → IN2
  • D7 → IN3
  • D8 → IN4
  • DC Motors connected to L298N motor outputs
  • Battery pack +V → L298N +V, GND shared with Wemos D1

5. Understanding the MPU6050 Sensor

The MPU6050 is a 6-axis sensor that provides accelerometer and gyroscope readings. It detects tilt and rotation along X, Y, and Z axes. In this project:

  • X-axis tilt: Left/Right movement of hand
  • Y-axis tilt: Forward/Backward movement of hand
  • Z-axis: Optional for advanced gestures (like spinning)

The sensor communicates with the Wemos D1 via I2C (SDA and SCL). Correct connections and power supply (3.3V) are critical.

6. Remote Arduino Code

Upload the following code to the remote Wemos D1. This code reads MPU6050 data and sends movement commands over Wi-Fi:

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include "MPU6050.h"

const char* ssid = "GestureTank";
const char* pass = "12345678";
WiFiUDP udp;
IPAddress tankIP(192,168,4,1);
const int udpPort = 4210;

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz;

void setup() {
  Wire.begin();
  mpu.initialize();
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) delay(200);
}

void loop() {
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  String cmd = "S";
  if (ay > 8000) cmd = "F";
  else if (ay < -8000) cmd = "B";
  else if (ax > 8000) cmd = "L";
  else if (ax < -8000) cmd = "R";
  udp.beginPacket(tankIP, udpPort);
  udp.print(cmd);
  udp.endPacket();
  delay(50);
}

7. Tank Arduino Code

Upload the following code to the tank Wemos D1 to receive commands and drive the motors:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "GestureTank";
const char* pass = "12345678";

WiFiUDP udp;
const int udpPort = 4210;

#define IN1 D5
#define IN2 D6
#define IN3 D7
#define IN4 D8

void setup() {
  pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  WiFi.softAP(ssid, pass);
  udp.begin(udpPort);
}

void move(String c) {
  if (c == "F") {digitalWrite(IN1,1); digitalWrite(IN2,0); digitalWrite(IN3,1); digitalWrite(IN4,0);}
  else if (c == "B") {digitalWrite(IN1,0); digitalWrite(IN2,1); digitalWrite(IN3,0); digitalWrite(IN4,1);}
  else if (c == "L") {digitalWrite(IN1,0); digitalWrite(IN2,1); digitalWrite(IN3,1); digitalWrite(IN4,0);}
  else if (c == "R") {digitalWrite(IN1,1); digitalWrite(IN2,0); digitalWrite(IN3,0); digitalWrite(IN4,1);}
  else {digitalWrite(IN1,0); digitalWrite(IN2,0); digitalWrite(IN3,0); digitalWrite(IN4,0);}
}

void loop() {
  int psize = udp.parsePacket();
  if (psize) {
    char buf[10]; udp.read(buf,10);
    String c = String(buf).substring(0,1);
    move(c);
  }
}

8. How It Works

The remote module reads hand tilt via the MPU6050. Depending on tilt, it sends “F”, “B”, “L”, “R” or “S” commands to the car using UDP. The car module receives the command and activates the motors via the L298N driver. Forward/backward and left/right motions are mapped directly to motor outputs, giving intuitive gesture control.

9. Testing Your Project

  1. Upload both codes to the respective Wemos boards
  2. Power up the car and place it on a flat surface
  3. Open Serial Monitor on remote to view MPU6050 readings
  4. Tilt your hand forward/backward/left/right to see the car respond
  5. Adjust MPU6050 sensitivity by changing threshold values in code if movement is too fast or slow

10. Advanced Modifications

  • Add PWM motor speed control for smoother movement
  • Integrate ESP32-CAM for real-time video streaming
  • Add buzzer or LED indicators for feedback on movement
  • Use multiple MPU6050s for gesture combinations
  • Implement mobile app integration for hybrid control

11. Common Issues and Troubleshooting

  • Remote not connecting: Check SSID/password, restart boards
  • Motors not moving: Verify motor driver wiring and battery
  • Car moves in wrong direction: Swap motor wires or invert logic in code
  • MPU6050 not detected: Check SDA/SCL wiring and 3.3V power
  • Laggy response: Reduce delay(50) in remote code or improve Wi-Fi signal

12. Learning Insights for Beginners

This project teaches:

  • Basics of I2C communication with sensors
  • Wi-Fi communication using UDP
  • Real-time motor control
  • Troubleshooting electronics and code integration
  • Mapping sensor readings to actionable commands

13. Conclusion

This is the second project in the Arduino Maker Series Under 1000. Your Gesture Controlled Wireless Car is now ready! A fun, practical, and interactive project perfect for makers exploring wireless control, robotics, and IoT.

By Kaushal Haladi

Comments

Popular Posts