
How to Build an Obstacle Avoidance Robot Car with Arduino
Build the car around an Arduino UNO, an HC-SR04 ultrasonic sensor, and an L298N motor driver. The sensor measures 2 to 450 cm ahead, and the driver runs 2 DC motors at 2A per bridge. The UNO R3 board costs $9.27. A TT motor set with 65mm wheels costs $9.63 and gives 800 gf cm of torque.
Quick facts
| Fact | Value |
|---|---|
| HC-SR04 sensor | 2 to 450 cm range, 0.3 cm precision, 5V |
| L298N driver | 5 to 35V, 2A per bridge, built-in 5V regulator |
| UNO R3 board | ATmega328P, 16MHz, 14 digital pins |
| TT motor set | 3 to 6V DC, 1:48 gear ratio, 800 gf cm |
| IR sensor | 2 to 30 cm adjustable, 35 degree angle |
| TCRT5000 sensor | 1 to 25 mm adjustable, 4-pack |
How does the HC-SR04 sensor measure distance?
The sensor sends a sound pulse and times its echo over 2 to 450 cm.
It measures with 0.3 cm precision on 5V. That precision suits a car that must stop before it hits a wall.
The module costs from $4.01, with a module-only option at $5.25. Wire its trigger and echo pins to 2 digital pins on the UNO.
Which motor driver runs the car wheels?
The L298N driver runs 2 DC motors at 2A per bridge.
It takes 5 to 35V and drives 2 DC motors or 1 stepper motor. A built-in 5V regulator feeds the logic side.
One driver costs $7.17, a 2-pack costs $12.65, and a 4-pack costs $25.99. Keep one spare for the next build.
Which motors and wheels move the car?
The TT motor set gives 2 motors and 2 wheels for $9.63.
Each motor runs on 3 to 6V DC with a 1:48 gear ratio. It gives 800 gf cm of torque through the gearbox.
The 65mm wheels fit the motor shafts with no extra adapter. Mount one motor on each side for a 2-wheel drive car.
How do IR and line sensors add to the car?
The IR sensor stops the car 2 to 30 cm from an object.
It uses a 35 degree angle and an LM393 comparator on 3.3 to 5V. The 5-pack costs $6.20, and the 10-pack costs $8.85.
The TCRT5000 tracks a line at 1 to 25 mm with a digital output. Its 4-pack costs $7.02 for a line-following car.
How do you power the car?
Power the motors from a battery pack through the L298N driver.
The driver takes 5 to 35V, so a 6V or 12V pack suits the car. The UNO board takes power over USB or its 5V pin.
Join the grounds of the motor supply and the UNO board. A missing common ground makes the motors ignore commands.
The JST-XH kit costs $12.72 and holds 500 housings, terminals, and pin headers. It builds the leads the car needs.
How the options compare
| Part | Key spec | Price |
|---|---|---|
| HC-SR04 sensor | 2 to 450 cm, 0.3 cm precision, 5V | From $4.01 |
| IR obstacle sensor | 2 to 30 cm, 35 degree angle | $6.20, 5-pack |
| TCRT5000 sensor | 1 to 25 mm, digital output | $7.02, 4-pack |
| L298N driver | 5 to 35V, 2A per bridge | $7.17 |
| TT motor set | 3 to 6V, 1:48, 800 gf cm | $9.63 |
| UNO R3 board | ATmega328P, 16MHz, 14 digital pins | $9.27 |
How do you build the obstacle avoidance robot car?
- Mount the TT motors and 65mm wheels on the chassis.
- Fit the HC-SR04 sensor on the front of the car.
- Wire the L298N driver to the motors and the battery pack.
- Connect the sensor trigger and echo pins to the UNO board.
- Load the sketch that stops the car when the sensor reads under 30 cm.
- Test the car on the floor and tune the stop distance.
Parts that fit this guide
In-stock parts ship from the New York, USA warehouse in 1-2 business days. Prices below are the live store prices we verified on November 10, 2026.
HC-SR04 Ultrasonic Ranging Sensor Module for Arduino, 2-450cm, with Mounting Bracket Options ($4.01)
HC-SR04 sensor at $4.01 listed, with a module-only option at $5.25. It measures 2 to 450 cm with 0.3 cm precision on 5V.
L298N Dual H-Bridge Motor Driver Module for Arduino, DC / Stepper, 5-35V, 2A ($7.17)
L298N driver at $7.17 for 1 piece. It runs 2 DC motors or 1 stepper motor at 2A per bridge on 5 to 35V.
TT Motor 130 Gear Motor + 65mm Wheel Set, 2 Motors + 2 Wheels, 3-6V DC, for Arduino Smart Car Robot ($9.63)
TT motor set at $9.63. It gives 2 motors and 2 wheels on 3 to 6V DC, with a 1:48 gear ratio and 800 gf cm of torque.
UNO R3 Compatible Development Board, ATmega328P CH340G – USB / Type-C ($9.27)
UNO R3 compatible board at $9.27 to $10.64 by version. It carries an ATmega328P chip, runs at 16MHz, and gives 14 digital pins and 6 analog inputs.
IR Infrared Obstacle Avoidance Sensor Module, 5-Pack / 10-Pack ($6.20)
IR obstacle sensor at $6.20 for a 5-pack. It detects 2 to 30 cm at a 35 degree angle on 3.3 to 5V.
Shop the full range: Robot Chassis and Kits at Quality RC Parts. See also: Related guide.
Frequently asked questions
How far ahead does the HC-SR04 sensor see?
It measures 2 to 450 cm with 0.3 cm precision on 5V. The module costs from $4.01.
What motor driver does the car need?
The L298N driver at $7.17. It runs 2 DC motors at 2A per bridge on 5 to 35V.
Can the car follow a line too?
Yes. The TCRT5000 sensor tracks a line at 1 to 25 mm, and its 4-pack costs $7.02.
How do I power the car motors and the UNO board?
Power the motors through the L298N driver from a battery pack, and join the grounds of the motor supply and the UNO board.
Sources
- HC-SR04 ultrasonic sensor datasheet
- SparkFun L298N motor driver datasheet
- Arduino getting started guide
Last updated: November 10, 2026.
