🚗 Autonomous Robot Car
Build a self-navigating robot car with ultrasonic obstacle avoidance, line following, and Bluetooth control.
Overview
An autonomous robot car is the gateway project to real robotics engineering. You'll build a wheeled robot that can navigate its environment without any human input — detecting obstacles with ultrasonic sensors, following a black line on the floor, and accepting Bluetooth commands from your phone.
What you'll learn: DC motor control with L298N H-bridge, PWM speed control, ultrasonic distance sensing, IR line following, HC-05 Bluetooth serial communication, and multi-mode state machine programming.
Estimated time: 3–5 hours (build + tune). Difficulty: ⭐⭐⭐⭐ Expert — requires comfort with wiring, motor drivers, and multi-sensor logic.
Components Needed
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Nano | ATmega328P, 5V | 1 | Compact — fits on the chassis easily |
| 4WD Robot Car Chassis | Acrylic, 4 DC motors | 1 | Kit includes motors, wheels, and mounting hardware |
| L298N Motor Driver | Dual H-bridge, 2A/ch | 1 | Controls 4 motors in 2 pairs |
| HC-SR04 Ultrasonic | 2–400cm, ±3mm | 1 | Front-mounted for obstacle detection |
| SG90 Servo Motor | 0–180°, 5V | 1 | Pans the ultrasonic sensor left/right |
| IR Line Sensors | TCRT5000, 3.3–5V | 2 | Left and right, for line following mode |
| HC-05 Bluetooth Module | Serial, 3.3V logic | 1 | For phone control via Bluetooth app |
| Li-Po Battery | 7.4V 2S, 1500mAh+ | 1 | Powers motors and Arduino |
| Voltage Regulator | LM7805, 5V 1A | 1 | Steps down battery voltage for Arduino |
| Jumper Wires + PCB | Male-to-Male, Mini PCB | set | For clean wiring on the chassis |
Step-by-Step Tutorial
Assemble the Chassis
Wire the Motor Driver
IN1/IN2 → Arduino pins 2,3 (left motors), IN3/IN4 → pins 4,5 (right motors). ENA → pin 6 (PWM), ENB → pin 9 (PWM). Motor outputs OUT1–OUT4 to the 4 motors in pairs. L298N 12V input from battery, 5V output to Arduino VIN.Mount and Wire the Ultrasonic Sensor
10. HC-SR04: VCC → 5V, GND → GND, TRIG → pin 11, ECHO → pin 12.Wire the IR Line Sensors
A0 (left) and A1 (right). Adjust the onboard potentiometer until the LED turns on over black tape and off over white.Wire the Bluetooth Module
7 (SoftwareSerial RX), RX → Arduino pin 8 via a voltage divider (1kΩ + 2kΩ) since HC-05 RX is 3.3V logic. Pair with your phone using code 1234.Upload the Code and Calibrate
LINE_THRESHOLD until it tracks cleanly. Test obstacle avoidance by placing your hand in front — it should stop, scan left/right, and turn to the clearer side.Control via Bluetooth
F=forward, B=back, L=left, R=right, S=stop, A=auto mode, X=line follow mode.BASE_SPEED (100–255) and SAFE_DIST for your surface and battery voltage. On carpet, increase speed; on smooth floors, reduce it. Always test obstacle avoidance on a clear floor before running line-follow mode.Code / Configuration
// Autonomous Robot Car — Volt X
// Modes: Bluetooth RC | Obstacle Avoidance | Line Following
#include <Servo.h>
#include <SoftwareSerial.h>
// ── Motor pins ──────────────────────────────────────────────
#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5
#define ENA 6
#define ENB 9
#define BASE_SPEED 180
// ── Ultrasonic ──────────────────────────────────────────────
#define TRIG 11
#define ECHO 12
#define SAFE_DIST 25 // cm
// ── Servo ───────────────────────────────────────────────────
#define SERVO_PIN 10
Servo scanServo;
// ── IR Line sensors ─────────────────────────────────────────
#define IR_LEFT A0Reviews & Ratings
Sign in to leave a review
Loading reviews…