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
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
DC Mini Metal Gear Motor
- Description: Motor used for driving the wheels of the bot.
- Pins: IN1, IN2
DC Mini Metal Gear Motor
- Description: Motor used for driving the wheels of the bot.
- Pins: IN1, IN2
DRV8833
- Description: Motor driver used to control the DC motors.
- Pins: EEP, OUT1, OUT2, OUT3, OUT4, ULT, IN4, IN3, GND, VCC, IN1, IN2
12V Battery
- Description: Power source for the circuit.
- Pins: VCC, GND
Pushbutton
- Description: Button used to control the movement of the bot.
- Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
Pushbutton
- Description: Button used to control the movement of the bot.
- Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
Pushbutton
- Description: Button used to control the movement of the bot.
- Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
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
- D34 connected to IN1 of DRV8833
- D35 connected to IN2 of DRV8833
- D32 connected to EEP of DRV8833
- D27 connected to Pin 1 (in) of Pushbutton
- D14 connected to Pin 1 (in) of Pushbutton
- D12 connected to Pin 1 (in) of Pushbutton
- D13 connected to Pin 1 (in) of Pushbutton
- VIN connected to VCC of 12V Battery and VCC of DRV8833
- GND connected to GND of 12V Battery, GND of DRV8833, and Pin 2 (in) of all Pushbuttons
- D2 connected to IN3 of DRV8833
- D4 connected to IN4 of DRV8833
DC Mini Metal Gear Motor
- IN1 connected to OUT2 of DRV8833
- IN2 connected to OUT1 of DRV8833
DC Mini Metal Gear Motor
- IN1 connected to OUT3 of DRV8833
- IN2 connected to OUT4 of DRV8833
DRV8833
- IN1 connected to D34 of ESP32
- IN2 connected to D35 of ESP32
- EEP connected to D32 of ESP32
- IN3 connected to D2 of ESP32
- IN4 connected to D4 of ESP32
- OUT2 connected to IN1 of DC Mini Metal Gear Motor
- OUT1 connected to IN2 of DC Mini Metal Gear Motor
- OUT3 connected to IN1 of DC Mini Metal Gear Motor
- OUT4 connected to IN2 of DC Mini Metal Gear Motor
- VCC connected to VCC of 12V Battery and VIN of ESP32
- GND connected to GND of 12V Battery, GND of ESP32, and Pin 2 (in) of all Pushbuttons
12V Battery
- VCC connected to VCC of DRV8833 and VIN of ESP32
- GND connected to GND of DRV8833, GND of ESP32, and Pin 2 (in) of all Pushbuttons
Pushbutton
- Pin 1 (in) connected to D27 of ESP32
- Pin 2 (in) connected to GND of 12V Battery, GND of DRV8833, GND of ESP32, and Pin 2 (in) of all Pushbuttons
Pushbutton
- Pin 1 (in) connected to D14 of ESP32
- Pin 2 (in) connected to GND of 12V Battery, GND of DRV8833, GND of ESP32, and Pin 2 (in) of all Pushbuttons
Pushbutton
- Pin 1 (in) connected to D12 of ESP32
- Pin 2 (in) connected to GND of 12V Battery, GND of DRV8833, GND of ESP32, and Pin 2 (in) of all Pushbuttons
Pushbutton
- Pin 1 (in) connected to D13 of ESP32
- Pin 2 (in) connected to GND of 12V Battery, GND of DRV8833, GND of ESP32, and Pin 2 (in) of all Pushbuttons
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
