Overview

Built a remote-controlled claw machine using ESP32 microcontroller with live video streaming through Zoom’s Video SDK. Players can control the machine from anywhere using simple serial commands.

Hardware Components

  • ESP32 development board
  • 4 DC motors for movement control
  • L298N motor driver module
  • 2 LED indicators
  • Separate power supplies for logic and motors

Implementation

Motor Control

ESP32 GPIO pins control 4 motors through L298N driver:

  • Motor 1: Forward/backward movement
  • Motor 2: Left/right movement
  • Motors 3-4: Claw mechanism

Command System

Text-based serial protocol for control commands.

void loop() {
  if (Serial.available() > 0) {
    String command = Serial.readStringUntil('\n');
    if (command == "forward") moveForward();
    else if (command == "backward") moveBackward();
    else if (command == "left") moveLeft();
    else if (command == "right") moveRight();
    else if (command == "light") activateGrab();
  }
}

Visual Feedback

LEDs blink different patterns to confirm commands:

  • 1 blink: Forward
  • 2 blinks: Backward
  • 3 blinks: Left
  • 4 blinks: Right
  • 5 blinks: Grab

Video Integration

Zoom Video SDK provides real-time video stream. Players watch the claw machine while sending commands.

Technical Challenges

Power Management: Separated motor power supply from ESP32 to prevent brownouts.

Network Latency: Reduced video quality and implemented fixed-duration movements. Achieved ~150ms latency.

Command Reliability: Added newline terminators and whitespace trimming for reliable command parsing.

Results

  • 85% command success rate
  • 150-200ms average latency
  • Successfully tested with 20 concurrent users

Technology Stack

Hardware: ESP32, L298N motor driver, DC motors
Software: Arduino framework, Zoom Video SDK
Communication: Serial protocol over WiFi

Source Code

GitHub: github.com/tanchunsiong/esp32-claw-machine

Contact


Project created September 2023