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

ESP32-Controlled DC Motor with 12V Battery and Motor Driver

View and Edit Project In Cirkit DesignerImage of ESP32-Controlled DC Motor with 12V Battery and Motor Driver

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a DC motor using an ESP32 microcontroller and a 2-channel motor driver. The ESP32 sends control signals to the motor driver, which in turn drives the motor. The motor is powered by a 12v battery, which also supplies power to the motor driver. The ESP32 is responsible for generating PWM (Pulse Width Modulation) signals and direction control to regulate the speed and direction of the motor.

Component List

12v Battery

DC Motor

Motor Driver 2 Channel

ESP32 (30 pin)

Wiring Details

12v Battery

DC Motor

Motor Driver 2 Channel

ESP32 (30 pin)

Documented Code

sketch.ino

void setup() {
  // Set motor control pins as outputs
  pinMode(23, OUTPUT); // DIR B
  pinMode(22, OUTPUT); // PWM B

  // Initialize motor control signals
  analogWrite(22, 100); // Set PWM B to a duty cycle for speed control
  digitalWrite(23, HIGH); // Set DIR B high for direction control
}

void loop() {
  // Main code loop
  // Motor control code would be placed here to run repeatedly
}

This code snippet is responsible for initializing the ESP32 microcontroller's pins that are connected to the motor driver. It sets pin 23 as the direction control (DIR B) and pin 22 as the PWM control (PWM B) for the motor driver. The analogWrite function is used to set the speed of the motor by adjusting the PWM duty cycle, and digitalWrite is used to set the direction. The loop function is currently empty, as the main control logic would be implemented here based on the specific application requirements.