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

ESP32 and L298N Motor Driver Wi-Fi Controlled Robotic Car

View and Edit Project In Cirkit DesignerImage of ESP32 and L298N Motor Driver Wi-Fi Controlled Robotic Car

Circuit Documentation

Summary

This circuit is designed to control multiple DC motors using an ESP32 microcontroller and L298N motor drivers. The motors are powered by a 12V battery and can be controlled via the ESP32, which is programmed to manage the motor speeds and directions.

Component List

  1. Motor and Wheels

    • Description: DC motor with attached wheels.
    • Pins: vcc, GND
  2. Rocker Switch (SPST)

    • Description: Single Pole Single Throw (SPST) rocker switch.
    • Pins: 1, 2
  3. Battery 12V

    • Description: 12V battery for powering the circuit.
    • Pins: +, -
  4. L298N DC Motor Driver

    • Description: Dual H-Bridge motor driver for controlling DC motors.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  5. ESP32 (30 pin)

    • Description: ESP32 microcontroller with 30 pins.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3

Wiring Details

Motor and Wheels

Rocker Switch (SPST)

Battery 12V

L298N DC Motor Driver

ESP32 (30 pin)

Code Documentation

sketch.ino

#define ENA 12
#define ENB 5
#define ln1 14
#define ln2 27
#define ln3 17
#define ln4 18
#define ENA1 2
#define ENB1 4
#define ln11 35
#define ln21 34
#define ln31 33
#define ln41 32

int a[12] = {ENA, ENB, ln1, ln2, ln3, ln4, ENA1, ENB1, ln11, ln21, ln31, ln41};
int speed = 255;

const int freq = 5000;
const int resolution = 8;

void setup() {
  Serial.begin(115200);
  for (int i = 0; i < 12; i++) {
    pinMode(a[i], OUTPUT);
  }
  
  // Setup PWM channels
  ledcSetup(0, freq, resolution);
  ledcAttachPin(ENA, 0);
  ledcAttachPin(ENB, 1);
  ledcAttachPin(ENA1, 2);
  ledcAttachPin(ENB1, 3);
}

void loop() {
  ledcWrite(0, speed);
  ledcWrite(1, speed);
  ledcWrite(2, speed);
  ledcWrite(3, speed);
  
  digitalWrite(ln1, HIGH);
  digitalWrite(ln2, LOW);
  digitalWrite(ln3, HIGH);
  digitalWrite(ln4, LOW);
  digitalWrite(ln11, HIGH);
  digitalWrite(ln21, LOW);
  digitalWrite(ln31, HIGH);
  digitalWrite(ln41, LOW);
}

documentation.txt

This file is empty and does not contain any code.