My project uses many different, but simple, Arduino components that create an awesome obstacle avoiding car! I made this car in my school Robotics class as a final project. This obstacle avoiding machine uses an HC-SR04 sensor mounted on top of a servo to locate walls in a maze using echolocation. The 4 DC motors are powered by a 9V battery back that runs from an L298 chip. The Arduino, servo, and sensor are powered by a separate 9V battery.
Project Introduction
The "Obstacle Avoiding Car" is a cornerstone of hobbyist robotics. This project demonstrates how a simple vehicle can perceive its surroundings and make autonomous navigation decisions without human intervention. By integrating hardware for movement and sensory perception, you'll build a robot that explores a room by physically "seeing" obstacles and turning away from them.
Hardware Infrastructure & Components
- Arduino UNO: The master processor that interprets distance data and sends direction commands to the motors.
- HC-SR04 Ultrasonic Sensor: Positioned at the front of the car, this sensor acts like sonar. It calculates the distance to the nearest object by timing the "ping" and "echo" of high-frequency sound waves.
- L298 Dual H-Bridge Motor Driver: This module is essential for driving the DC Motors. Since the Arduino cannot provide enough current directly from its pins to spin motors, the L298 acts as a high-power switch controlled by the Arduino's logic signals.
- DC Motors and Wheels: Provide the mechanical force for movement. In my build, I used four DC motors.
- Power Supply: I used a 9V battery pack to power the motors via the L298, and a separate 9V battery to power the Arduino, servo, and sensor.
Navigation Logic and Algorithm
The robot follows a straightforward autonomous navigation loop:
- Constant Scanning: As the car moves forward, the Arduino continuously polls the ultrasonic sensor for a distance reading.
- Threshold Detection: If an obstacle is detected within a designated "danger zone" (in my case, less than 35cm), the car stops immediately.
- Maneuvering:
- The car backs up to create space.
- The servo rotates 90 degrees to the left for the sensor to scan the distance to the left wall.
- The servo then rotates 180 degrees to the right to scan the distance to the right wall.
- The Arduino compares the two readings. If the distance to the left wall is greater, the car turns 90 degrees left, and vice versa.
- Resuming Exploration: Once the turn is complete, the car resumes moving forward, continuing the scanning loop.
Educational Value
Building this car teaches fundamental engineering principles, including PWM (Pulse Width Modulation) for speed control, H-bridge theory for motor direction, and time-of-flight calculations for sensor integration. It’s a perfect launching pad for adding more sensors, like line-following IR arrays or encoder-based speed control. This project was fun to make! There are a few 3d printed parts, but none of them are fundamental.