Arduino-Controlled Robotic Sensor Platform with Ultrasonic and IR Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit is designed to interface an Arduino UNO with multiple sensors and a motor driver. It includes ultrasonic sensors (HC-SR04) for distance measurement, infrared sensors (Sensor FC-51 IR) for object detection, and an L298N DC motor driver for controlling motors. The circuit is powered by a 18650 Li-Ion battery, and a rocker switch is used to control the power supply to the motor driver. The Arduino UNO serves as the central processing unit, reading sensor inputs and controlling the motor driver accordingly.
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.
HC-SR04 Ultrasonic Sensor
- Ultrasonic distance measuring module
- It has 4 pins: VCC, TRIG, ECHO, and GND.
Sensor FC-51 IR
- Infrared obstacle avoidance sensor
- It has 3 pins: OUT, GND, and VCC.
L298N DC Motor Driver
- Dual H-Bridge motor driver
- It can drive two DC motors or one stepper motor.
- It has multiple input and output pins, including ENA, IN1, IN2, ENB, IN3, IN4, and power supply pins.
Rocker Switch
- A simple on/off switch
- It has 2 pins: input and output.
18650 Li-Ion Battery
- Rechargeable battery
- It has 2 pins: Positive and Negative.
Wiring Details
Arduino UNO
- 5V pin is connected to the VCC pins of all HC-SR04 Ultrasonic Sensors, both Sensor FC-51 IR modules, and the 5V pin of the L298N motor driver.
- GND pin is connected to the GND pins of all HC-SR04 Ultrasonic Sensors, both Sensor FC-51 IR modules, and the GND pin of the L298N motor driver.
- A4 pin is connected to the ENA pin of the L298N motor driver.
- A5 pin is connected to the ENB pin of the L298N motor driver.
- D13 pin is connected to the IN4 pin of the L298N motor driver.
- D12 pin is connected to the IN3 pin of the L298N motor driver.
- D11 pin is connected to the IN2 pin of the L298N motor driver.
- D10 pin is connected to the IN1 pin of the L298N motor driver.
- D9 pin is connected to the OUT pin of one Sensor FC-51 IR module.
- D8 pin is connected to the OUT pin of the other Sensor FC-51 IR module.
- D7 pin is connected to the ECHO pin of one HC-SR04 Ultrasonic Sensor.
- D6 pin is connected to the TRIG pin of the same HC-SR04 Ultrasonic Sensor.
- D5 pin is connected to the ECHO pin of another HC-SR04 Ultrasonic Sensor.
- D4 pin is connected to the TRIG pin of the same HC-SR04 Ultrasonic Sensor.
- D3 pin is connected to the ECHO pin of the third HC-SR04 Ultrasonic Sensor.
- D2 pin is connected to the TRIG pin of the same HC-SR04 Ultrasonic Sensor.
HC-SR04 Ultrasonic Sensors
- VCC pins are connected to the 5V output from the Arduino UNO.
- GND pins are connected to the GND on the Arduino UNO.
- TRIG and ECHO pins are connected to designated digital pins on the Arduino UNO for triggering and receiving the ultrasonic pulses.
Sensor FC-51 IR Modules
- VCC pins are connected to the 5V output from the Arduino UNO.
- GND pins are connected to the GND on the Arduino UNO.
- OUT pins are connected to designated digital pins on the Arduino UNO for detecting the presence of an obstacle.
L298N DC Motor Driver
- 5V pin is connected to the 5V output from the Arduino UNO.
- GND pin is connected to the GND on the Arduino UNO.
- ENA and ENB pins are connected to analog pins on the Arduino UNO for enabling the motor driver.
- IN1, IN2, IN3, and IN4 pins are connected to digital pins on the Arduino UNO for controlling the direction of the motors.
- 12V pin is connected to the output of the rocker switch.
Rocker Switch
- Input pin is connected to the Positive pin of the 18650 Li-Ion battery.
- Output pin is connected to the 12V input of the L298N motor driver.
18650 Li-Ion Battery
- Positive pin is connected to the input of the rocker switch.
- Negative pin is connected to the GND on the Arduino UNO.
Documented Code
void setup() {
// Initialize the motor driver pins as outputs
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(D13, OUTPUT);
pinMode(D12, OUTPUT);
pinMode(D11, OUTPUT);
pinMode(D10, OUTPUT);
// Initialize the IR sensor pins as inputs
pinMode(D9, INPUT);
pinMode(D8, INPUT);
// Initialize the ultrasonic sensor pins
pinMode(D7, INPUT); // ECHO pin
pinMode(D6, OUTPUT); // TRIG pin
pinMode(D5, INPUT); // ECHO pin
pinMode(D4, OUTPUT); // TRIG pin
pinMode(D3, INPUT); // ECHO pin
pinMode(D2, OUTPUT); // TRIG pin
}
void loop() {
// Main code to interact with sensors and control motors
}
Note: The provided code is a template and does not include specific logic for sensor reading or motor control. This should be implemented based on the requirements of the application.