Beginner4–6 h (estimate)7 parts
Obstacle-avoiding car
An ultrasonic sensor on a servo looks around and picks the clearer side.
Overview
A two-wheel car drives forward until an ultrasonic distance sensor sees something close, then stops, turns the sensor left and right on a micro servo, and turns toward the side with more space.
You will measure distance from the echo time, filter noisy readings, and write the behaviour as a small state machine (drive → stop → look → turn).
You will learn
- · Ultrasonic time-of-flight distance measurement
- · Filtering noisy readings
- · Servo control with the Servo library
- · State machines for robot behaviour
Parts list
| Part (generic) | Qty | Note |
|---|---|---|
| Arduino Uno-compatible board (5 V logic) | 1 | |
| Ultrasonic distance sensor module (HC-SR04-type, 5 V) | 1 | |
| Micro servo (SG90-class, 5 V) | 1 | Optional: without it the car turns on the spot to look. |
| Dual H-bridge DC motor driver module (L298N-type or TB6612FNG-type) | 1 | |
| Small DC gear motor with wheel | 2 | |
| Caster wheel, chassis plate, battery pack, switch | 1 each | |
| Jumper wires | as needed |
Generic part names only. Pinouts and logic levels vary between modules of the same type, so check the documentation of the exact module you have.
Tools
- · USB cable and the Arduino IDE
- · Screwdrivers
- · Multimeter
- · Tape measure or ruler
Safety
- · Test on the floor with space around it; keep it away from stairs.
- · Power the servo and motors from a supply that can handle their current, not from the USB port.
Learn the ideas first
Full build
- 01Assemble the chassis and motor driver
- 02Measure distance with the ultrasonic sensor
- 03Add the servo "neck" and scan left/right
- 04Write the drive–stop–look–turn state machine
- 05Filter readings and tune turn timing
Checking your account…