Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Powered 2-Wheel Sumo Bot with Pushbutton Control

View and Edit Project In Cirkit DesignerImage of ESP32-Powered 2-Wheel Sumo Bot with Pushbutton Control

Circuit Documentation

Summary

This document provides a detailed overview of a 2-Wheel Sumo Bot circuit. The circuit includes an ESP32 microcontroller, a DRV8833 motor driver, two DC Mini Metal Gear Motors, a 12V battery, and four pushbuttons. The ESP32 controls the motors via the DRV8833 motor driver based on inputs from the pushbuttons. The bot can move forward, backward, left, and right.

Component List

  1. ESP32

    • Description: Microcontroller used to control the motors and read pushbutton inputs.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT
  2. DC Mini Metal Gear Motor

    • Description: Motor used for driving the wheels of the bot.
    • Pins: IN1, IN2
  3. DC Mini Metal Gear Motor

    • Description: Motor used for driving the wheels of the bot.
    • Pins: IN1, IN2
  4. DRV8833

    • Description: Motor driver used to control the DC motors.
    • Pins: EEP, OUT1, OUT2, OUT3, OUT4, ULT, IN4, IN3, GND, VCC, IN1, IN2
  5. 12V Battery

    • Description: Power source for the circuit.
    • Pins: VCC, GND
  6. Pushbutton

    • Description: Button used to control the movement of the bot.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  7. Pushbutton

    • Description: Button used to control the movement of the bot.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  8. Pushbutton

    • Description: Button used to control the movement of the bot.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  9. Pushbutton

    • Description: Button used to control the movement of the bot.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)

Wiring Details

ESP32

DC Mini Metal Gear Motor

DC Mini Metal Gear Motor

DRV8833

12V Battery

Pushbutton

Pushbutton

Pushbutton

Pushbutton

Code Documentation

/*
 * 2-Wheel Sumo Bot Control Code with Pushbutton Control
 * This code controls two DC motors via the DRV8833 motor driver using an ESP32.
 * The bot can move forward, backward, left, and right based on pushbutton inputs.
 */

// Motor driver pins
const int motor1Pin1 = 34; // IN1 on DRV8833
const int motor1Pin2 = 35; // IN2 on DRV8833
const int motor2Pin1 = 2;  // IN3 on DRV8833
const int motor2Pin2 = 4;  // IN4 on DRV8833

// Pushbutton pins
const int buttonForward = 14; // Pushbutton for moving forward
const int buttonBackward = 27; // Pushbutton for moving backward
const int buttonLeft = 12; // Pushbutton for turning left
const int buttonRight = 13; // Pushbutton for turning right

void setup() {
  // Set motor pins as outputs
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin1, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
  // Set pushbutton pins as inputs
  pinMode(buttonForward, INPUT);
  pinMode(buttonBackward, INPUT);
  pinMode(buttonLeft, INPUT);
  pinMode(buttonRight, INPUT);
}

void loop() {
  // Read pushbutton states
  bool forward = digitalRead(buttonForward);
  bool backward = digitalRead(buttonBackward);
  bool left = digitalRead(buttonLeft);
  bool right = digitalRead(buttonRight);

  // Control motors based on pushbutton states
  if (forward) {
    moveForward();
  } else if (backward) {
    moveBackward();
  } else if (left) {
    turnLeft();
  } else if (right) {
    turnRight();
  } else {
    stopMotors();
  }
}

void moveForward() {
  digitalWrite(motor1Pin1, HIGH);
  digitalWrite(motor1Pin2, LOW);
  digitalWrite(motor2Pin1, HIGH);
  digitalWrite(motor2Pin2, LOW);
}

void moveBackward() {
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, HIGH);
  digital