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

ESP32-Controlled 4-Wheel Robot with L293D Motor Drivers

View and Edit Project In Cirkit DesignerImage of ESP32-Controlled 4-Wheel Robot with L293D Motor Drivers

Circuit Documentation

Summary

This circuit is designed to control four 12V geared motors using two L293D motor driver ICs, which are interfaced with an ESP32 microcontroller. The ESP32 is responsible for generating control signals to drive the motors in forward, backward, left, and right directions. The motors are powered by a 12V battery, while the ESP32 is powered by a separate 5V battery to ensure stable operation. The circuit includes provisions for motor control through GPIO pins and includes a delay-based sequence in the embedded code to demonstrate the motor control functionality.

Component List

ESP32 (30 pin)

L293D Motor Driver IC

12V Geared Motor

5V Battery

12V Battery

Wiring Details

ESP32 (30 pin)

L293D Motor Driver IC (First Instance)

L293D Motor Driver IC (Second Instance)

12V Geared Motors

5V Battery

12V Battery

Documented Code

// Define motor control pins
int A=4, B=5, C=18, D=19;
int E=13, F=12, G=14, H=27;
int t=1000; // Delay time in milliseconds

// Function prototypes for motor control
void f_w();
void b_w();
void r_w();
void l_w();

void setup() 
{
  // Initialize motor control pins as outputs
  pinMode(A,OUTPUT);
  pinMode(B,OUTPUT);
  pinMode(C,OUTPUT);
  pinMode(D,OUTPUT);
  pinMode(E,OUTPUT);
  pinMode(F,OUTPUT);
  pinMode(G,OUTPUT);
  pinMode(H,OUTPUT);
}

void loop()
{
  // Sequence of motor movements
  f_w(); // Forward
  delay(t);
  b_w(); // Backward
  delay(t);
  r_w(); // Right
  delay(t);
  l_w(); // Left
  delay(t);
}

// Function to move forward
void f_w()
{
  digitalWrite(A,1);
  digitalWrite(B,0);
  digitalWrite(C,1);
  digitalWrite(D,0);
  digitalWrite(E,1);
  digitalWrite(F,0);
  digitalWrite(G,1);
  digitalWrite(H,0);
}

// Function to move backward
void b_w()
{
  digitalWrite(A,0);
  digitalWrite(B,1);
  digitalWrite(C,0);
  digitalWrite(D,1);
  digitalWrite(E,0);
  digitalWrite(F,1);
  digitalWrite(G,0);
  digitalWrite(H,1);
}

// Function to turn right
void r_w()
{
  digitalWrite(A,1);
  digitalWrite(B,0);
  digitalWrite(C,1);
  digitalWrite(D,0);
  digitalWrite(E,0);
  digitalWrite(F,0);
  digitalWrite(G,0);
  digitalWrite(H,0);
}

// Function to turn left
void l_w()
{
  digitalWrite(A,0);
  digitalWrite(B,1);
  digitalWrite(C,0);
  digitalWrite(D,1);
  digitalWrite(E,0);
  digitalWrite(F,0);
  digitalWrite(G,0);
  digitalWrite(H,0);
}

The code provided is for the ESP32 microcontroller and is written in Arduino C/C++. It defines a set of functions to control the motors connected through the L293D motor driver ICs. The setup() function initializes the GPIO pins as outputs, and the loop() function calls the motor control functions in a sequence to demonstrate the motor's forward, backward, right, and left movements. Each motor control function sets the appropriate GPIO pins high or low to control the direction of the motors.