Arduino-Controlled Dual DC Motor Robot with IR and Ultrasonic Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control two DC motors using an Arduino UNO microcontroller and an L298N DC motor driver. It includes two IR sensors for input and an HC-SR04 Ultrasonic Sensor for distance measurement. The circuit is powered by a 12V battery, which supplies power to the motor driver and the Arduino UNO, which in turn powers the sensors.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
DC Motor (x2)
- An electric motor that runs on direct current (DC) electricity.
- It has two pins for power and ground.
L298N DC Motor Driver
- A dual H-bridge motor driver that can drive two DC motors or one stepper motor.
- It has pins for motor outputs, power supply, and control inputs.
IR Sensor (x2)
- An infrared sensor that can detect obstacles and measure distances using IR light.
- It has three pins: out, ground (gnd), and power (vcc).
HC-SR04 Ultrasonic Sensor
- An ultrasonic distance sensor that can measure distances by emitting ultrasonic waves and measuring the time it takes for the echo to return.
- It has four pins: VCC, TRIG, ECHO, and GND.
Battery 12V
- A 12-volt battery that provides power to the circuit.
- It has two pins: positive (+) and negative (-).
Wiring Details
Arduino UNO
- 5V and GND pins are used to power the IR sensors and the HC-SR04 Ultrasonic Sensor.
- Analog pins A0 and A1 are connected to the output of the IR sensors.
- Digital pins D13 and D12 are connected to the ECHO and TRIG pins of the HC-SR04 Ultrasonic Sensor, respectively.
- Digital pins D11, D10, D9, D8, D7, and D6 are connected to the ENB, ENA, IN1, IN2, IN3, and IN4 pins of the L298N motor driver to control the motors.
DC Motors
- Each motor has two pins connected to the OUT1/OUT2 and OUT3/OUT4 pairs on the L298N motor driver.
L298N DC Motor Driver
- 12V and GND pins are connected to the 12V battery.
- ENA and ENB pins are connected to the Arduino for enabling the motor outputs.
- IN1, IN2, IN3, and IN4 pins are connected to the Arduino for controlling the direction of the motors.
- OUT1, OUT2, OUT3, and OUT4 pins are connected to the DC motors.
IR Sensors
- VCC pins are connected to the 5V output on the Arduino.
- GND pins are connected to the ground on the Arduino.
- OUT pins are connected to the A0 and A1 analog inputs on the Arduino.
HC-SR04 Ultrasonic Sensor
- VCC pin is connected to the 5V output on the Arduino.
- GND pin is connected to the ground on the Arduino.
- TRIG and ECHO pins are connected to the D12 and D13 digital pins on the Arduino, respectively.
Battery 12V
- The positive (+) pin is connected to the 12V input on the L298N motor driver.
- The negative (-) pin is connected to the ground.
Documented 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
(No additional documentation provided for the code)
(Note: The actual functionality of the code is not provided in the input, so the code section only includes the template structure for an Arduino sketch. The user should implement the setup and loop functions to control the motors and read sensor data based on the specific requirements of their project.)