ESP32 and Arduino Mega 2560 Controlled Multi-Motor System with IR Sensing
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit integrates an ESP32 microcontroller with an Arduino Mega 2560 to control multiple DC motors via L298N motor drivers. IR sensors are included for input, and a 12V power supply is used to power the motors and motor drivers. The ESP32 and Arduino Mega communicate via serial connection, and the Arduino Mega directly controls the motor drivers and reads the IR sensors.
Component List
Microcontrollers
- ESP32 (30 pin): A microcontroller with Wi-Fi and Bluetooth capabilities, featuring a wide range of GPIO pins.
- Arduino Mega 2560: A microcontroller board based on the ATmega2560, with numerous digital input/output pins, analog inputs, and a larger amount of memory.
Motor Drivers
- L298N DC motor driver: A high-power motor driver capable of driving up to two DC motors.
Sensors
- IR Sensor: An infrared sensor used for object detection or distance measurement.
Motors
- DC Motor: A simple electric motor that is driven by DC power.
Power Supply
- POWER SUPPLY 12V 5AMP: Provides the necessary power to the DC motors and motor drivers.
Miscellaneous
- Power 220V: The main AC power source for the 12V power supply.
Comments
- Comment: Used for annotations or notes within the circuit design, not an actual physical component.
Wiring Details
ESP32 (30 pin)
- Serial communication with Arduino Mega 2560 via TX0 and RX0.
- Ground (GND) connection shared with Arduino Mega 2560.
- 3.3V power supply shared with Arduino Mega 2560.
Arduino Mega 2560
- Serial communication with ESP32.
- PWM outputs (D2-D9) connected to L298N motor driver ENA and ENB pins for motor speed control.
- Digital outputs (D22-D39) connected to L298N motor driver IN1-IN4 pins for motor direction control.
- 5V output shared with IR sensors and L298N motor drivers.
- Ground (GND) connection shared with all components.
L298N DC motor driver
- Motor control inputs from Arduino Mega 2560 (ENA, ENB, IN1-IN4).
- Motor outputs connected to DC motors.
- 12V power input from the 12V power supply.
- 5V output shared with Arduino Mega 2560.
- Ground (GND) connection shared with all components.
IR Sensor
- Output connected to Arduino Mega 2560 digital inputs (D38, D39).
- VCC connected to Arduino Mega 2560 5V output.
- Ground (GND) connection shared with Arduino Mega 2560.
DC Motor
- Connected to L298N motor driver outputs (OUT1-OUT4).
POWER SUPPLY 12V 5AMP
- 220V AC input from power 220V.
- 12V DC output to L298N motor drivers.
- Ground (GND) connection shared with all components.
Power 220V
- Provides AC power to the 12V power supply.
Documented Code
Arduino Mega 2560 Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Additional Notes (documentation.txt)
No additional code documentation provided.