Arduino Mega 2560 Battery-Powered Dual DC Motor Control with IR Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit involves an Arduino Mega 2560 microcontroller, an L298N DC motor driver, two DC motors, two IR sensors, and a pair of 18650 Li-ion batteries. The Arduino Mega 2560 controls the DC motors through the L298N motor driver and receives input from the IR sensors. The power for the motor driver is supplied by the 18650 Li-ion batteries.
Component List
Arduino Mega 2560
- Description: A microcontroller board based on the ATmega2560.
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
L298N DC Motor Driver
- Description: A dual H-Bridge motor driver that allows control of two 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
DC Motor
- Description: A simple DC motor.
- Pins: pin 1, pin 2
18650 Li-ion Battery x 2
- Description: A pair of 18650 Li-ion batteries.
- Pins: +, -
IR Sensor
- Description: An infrared sensor used for object detection.
- Pins: out, gnd, vcc
Wiring Details
Arduino Mega 2560
- 5V connected to vcc of IR Sensor (Instance 1)
- GND connected to gnd of IR Sensor (Instance 1)
- D2 PWM connected to out of IR Sensor (Instance 1)
- D3 PWM connected to out of IR Sensor (Instance 2)
- D5 PWM connected to ENA of L298N DC Motor Driver
- D6 PWM connected to ENB of L298N DC Motor Driver
- D8 PWM connected to IN1 of L298N DC Motor Driver
- D9 PWM connected to IN2 of L298N DC Motor Driver
- D10 PWM connected to IN3 of L298N DC Motor Driver
- D11 PWM connected to IN4 of L298N DC Motor Driver
- GND connected to gnd of IR Sensor (Instance 2)
- 5V connected to vcc of IR Sensor (Instance 2)
L298N DC Motor Driver
- OUT1 connected to pin 2 of DC Motor (Instance 1)
- OUT2 connected to pin 1 of DC Motor (Instance 1)
- 12V connected to + of 18650 Li-ion Battery x 2
- GND connected to - of 18650 Li-ion Battery x 2
- OUT3 connected to pin 2 of DC Motor (Instance 2)
- OUT4 connected to pin 1 of DC Motor (Instance 2)
DC Motor (Instance 1)
- pin 1 connected to OUT2 of L298N DC Motor Driver
- pin 2 connected to OUT1 of L298N DC Motor Driver
DC Motor (Instance 2)
- pin 1 connected to OUT4 of L298N DC Motor Driver
- pin 2 connected to OUT3 of L298N DC Motor Driver
18650 Li-ion Battery x 2
- + connected to 12V of L298N DC Motor Driver
- - connected to GND of L298N DC Motor Driver
IR Sensor (Instance 1)
- vcc connected to 5V of Arduino Mega 2560
- gnd connected to GND of Arduino Mega 2560
- out connected to D2 PWM of Arduino Mega 2560
IR Sensor (Instance 2)
- vcc connected to 5V of Arduino Mega 2560
- gnd connected to GND of Arduino Mega 2560
- out connected to D3 PWM of Arduino Mega 2560
Code Documentation
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:
}
documentation.txt