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

ESP32-Controlled Omni-Directional AGV with Traffic Light Management and Servo Actuation

View and Edit Project In Cirkit DesignerImage of ESP32-Controlled Omni-Directional AGV with Traffic Light Management and Servo Actuation

Circuit Documentation

Summary

This circuit is designed to control a three-wheeled omnidirectional AGV (Automated Guided Vehicle) using an ESP32 microcontroller. The circuit includes a servo motor (MG996R) for steering and a traffic light LED system for signaling. The ESP32 controls two L298N DC motor drivers, which in turn drive three DC motors for the movement of the AGV. Additionally, the circuit incorporates MT3608 boost converters to step up the voltage for the motor drivers and a battery mount for power supply.

Component List

Microcontroller

Motor Drivers

Traffic Light

Motors

Servo Motor

Boost Converters

Power Supply

Switch

Servo

Wiring Details

ESP32 (30 pin)

L298N DC Motor Driver (First Instance)

L298N DC Motor Driver (Second Instance)

Traffic Light

DC Motors

MG996R Servo Motor

MT3608 Boost Converters

4 x AAA Battery Mount

Toggle Switch

Servo

Documented Code

/*
 * Carro AGV com três rodas omini multidirecional
 * Controlado por ESP32
 * Inclui controle de servomotor MG996R e semáforo de LED RGB
 */

#include <Servo.h>

// Pin definitions
#define SERVO_PIN 18
#define MOTOR1_ENA 23
#define MOTOR1_IN1 14
#define MOTOR1_IN2 22
#define MOTOR2_ENB 21
#define MOTOR2_IN3 15
#define MOTOR2_IN4 19
#define MOTOR3_ENB 4
#define MOTOR3_IN3 5
#define MOTOR3_IN4 2
#define TRAFFIC_LIGHT_RED 27
#define TRAFFIC_LIGHT_YELLOW 26
#define TRAFFIC_LIGHT_GREEN 25

Servo myservo;

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize servo motor
  myservo.attach(SERVO_PIN);

  // Initialize motor control pins
  pinMode(MOTOR1_ENA, OUTPUT);
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  pinMode(MOTOR2_ENB, OUTPUT);
  pinMode(MOTOR2_IN3, OUTPUT);
  pinMode(MOTOR2_IN4, OUTPUT);
  pinMode(MOTOR3_ENB, OUTPUT);
  pinMode(MOTOR3_IN3, OUTPUT);
  pinMode(MOTOR3_IN4, OUTPUT);

  // Initialize traffic light pins
  pinMode(TRAFFIC_LIGHT_RED, OUTPUT);
  pinMode(TRAFFIC_LIGHT_YELLOW, OUTPUT);
  pinMode(TRAFFIC_LIGHT_GREEN, OUTPUT);
}

void loop() {
  // Example: Move servo to 90 degrees
  myservo.write(90);
  delay(1000);

  // Example: Control motors
  digitalWrite(MOTOR1_ENA, HIGH);
  digitalWrite(MOTOR1_IN1, HIGH);
  digitalWrite(MOTOR1_IN2, LOW);
  digitalWrite(MOTOR2_ENB, HIGH);
  digitalWrite(MOTOR2_IN3, HIGH);
  digitalWrite(MOTOR2_IN4, LOW);
  digitalWrite(MOTOR3_ENB, HIGH);
  digitalWrite(MOTOR3_IN3, HIGH);
  digitalWrite(MOTOR3_IN4, LOW);
  delay(2000);

  // Stop motors
  digitalWrite(MOTOR1_ENA, LOW);
  digitalWrite(MOTOR2_ENB, LOW);
  digitalWrite(MOTOR3_ENB, LOW);
  delay(1000);

  // Example: Traffic light sequence
  digitalWrite(TRAFFIC_LIGHT_RED, HIGH);
  delay(1000);
  digitalWrite(TRAFFIC_LIGHT_RED, LOW);
  digitalWrite(TRAFFIC_LIGHT_YELLOW, HIGH);
  delay(1000);
  digitalWrite(TRAFFIC_LIGHT_YELLOW, LOW);
  digitalWrite(TRAFFIC_LIGHT_GREEN, HIGH);
  delay(1000);
  digitalWrite(TRAFFIC_LIGHT_GREEN, LOW);
}

This code is responsible for initializing and controlling the various components of the AGV. It sets up the servo motor and the motor drivers, and it includes an example of how to move the servo and control the motors. Additionally, it demonstrates a simple traffic light sequence using the connected LEDs.