Circuit Documentation
Summary
This circuit is designed to control two DC motors using an Arduino UNO and an L298N DC motor driver. It also includes two IR sensors for object detection and an HC-SR04 ultrasonic sensor for distance measurement. The circuit is powered by a 12V battery, which also supplies power to the motor driver. The Arduino UNO manages the sensors and motor driver through its GPIO pins.
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.
L298N DC Motor Driver
- A dual H-bridge motor driver that can drive two DC motors or one stepper motor.
- It has two enable inputs and four input pins to control the motor's direction.
DC Motor (x2)
- A simple electric motor that converts electrical energy into mechanical energy.
- It has two pins for power connection.
Battery 12V
- A 12-volt battery that provides power to the circuit.
- It has a positive and a negative terminal.
HC-SR04 Ultrasonic Sensor
- An ultrasonic distance sensor that can measure distances from 2cm to 400cm.
- It has four pins: VCC, TRIG, ECHO, and GND.
IR Sensor (x2)
- An infrared sensor used for object detection.
- It has three pins: out, gnd, and vcc.
Wiring Details
Arduino UNO
- 5V: Connected to VCC of both IR sensors and the HC-SR04 ultrasonic sensor.
- GND: Common ground with the L298N motor driver, both IR sensors, and the HC-SR04 ultrasonic sensor.
- A0: Connected to the 'out' pin of one IR sensor.
- A1: Connected to the 'out' pin of the other IR sensor.
- D13: Connected to the 'ECHO' pin of the HC-SR04 ultrasonic sensor.
- D12: Connected to the 'TRIG' pin of the HC-SR04 ultrasonic sensor.
- D11: Connected to the 'ENB' pin of the L298N motor driver.
- D10: Connected to the 'ENA' pin of the L298N motor driver.
- D9: Connected to the 'IN1' pin of the L298N motor driver.
- D8: Connected to the 'IN2' pin of the L298N motor driver.
- D7: Connected to the 'IN3' pin of the L298N motor driver.
- D6: Connected to the 'IN4' pin of the L298N motor driver.
L298N DC Motor Driver
- GND: Connected to the common ground.
- 12V: Connected to the positive terminal of the 12V battery.
- OUT1, OUT2: Connected to one DC motor.
- OUT3, OUT4: Connected to the other DC motor.
DC Motors
- Each motor has two pins connected to the OUT pins of the L298N motor driver.
Battery 12V
- Positive terminal connected to the 12V pin of the L298N motor driver.
- Negative terminal connected to the common ground.
HC-SR04 Ultrasonic Sensor
- VCC: Connected to the 5V output of the Arduino UNO.
- TRIG: Connected to pin D12 of the Arduino UNO.
- ECHO: Connected to pin D13 of the Arduino UNO.
- GND: Connected to the common ground.
IR Sensors
- VCC: Connected to the 5V output of the Arduino UNO.
- GND: Connected to the common ground.
- OUT: Each sensor's output is connected to a separate analog input on the Arduino UNO (A0 and A1).
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
The code for the Arduino UNO is currently a template with empty setup and loop functions. The setup function is intended to initialize the pins and any libraries needed for the sensors and motor driver. The loop function will contain the main logic for reading sensor values, processing them, and controlling the motors accordingly.
