← Back to Expert Projects
Expert · Project #01

🚗 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

ComponentSpecificationQtyNotes
Arduino NanoATmega328P, 5V1Compact — fits on the chassis easily
4WD Robot Car ChassisAcrylic, 4 DC motors1Kit includes motors, wheels, and mounting hardware
L298N Motor DriverDual H-bridge, 2A/ch1Controls 4 motors in 2 pairs
HC-SR04 Ultrasonic2–400cm, ±3mm1Front-mounted for obstacle detection
SG90 Servo Motor0–180°, 5V1Pans the ultrasonic sensor left/right
IR Line SensorsTCRT5000, 3.3–5V2Left and right, for line following mode
HC-05 Bluetooth ModuleSerial, 3.3V logic1For phone control via Bluetooth app
Li-Po Battery7.4V 2S, 1500mAh+1Powers motors and Arduino
Voltage RegulatorLM7805, 5V 1A1Steps down battery voltage for Arduino
Jumper Wires + PCBMale-to-Male, Mini PCBsetFor clean wiring on the chassis

📖 Step-by-Step Tutorial

1

Assemble the Chassis

Mount the 4 DC motors into the chassis brackets. Attach the wheels. Secure the top acrylic plate. Mount the L298N driver in the center, Arduino Nano at the rear, and servo + HC-SR04 at the front on a small bracket so the sensor can pan.
2

Wire the Motor Driver

Connect L298N: 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.
3

Mount and Wire the Ultrasonic Sensor

Attach the SG90 servo to the front bracket. Mount the HC-SR04 on the servo horn. Wire: servo signal → pin 10. HC-SR04: VCC → 5V, GND → GND, TRIG → pin 11, ECHO → pin 12.
4

Wire the IR Line Sensors

Mount one IR sensor on the left underside and one on the right, about 1cm from the ground. Wire each: VCC → 5V, GND → GND, OUT → pins A0 (left) and A1 (right). Adjust the onboard potentiometer until the LED turns on over black tape and off over white.
5

Wire the Bluetooth Module

HC-05: VCC → 5V, GND → GND, TX → Arduino pin 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.
6

Upload the Code and Calibrate

Upload the code below. Open Serial Monitor at 9600 baud. Place the robot on a line-following track and adjust 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.
7

Control via Bluetooth

Install a Bluetooth RC controller app (e.g. "Arduino Bluetooth Controller") on your phone. Pair with HC-05. Send F=forward, B=back, L=left, R=right, S=stop, A=auto mode, X=line follow mode.
💡
Tune 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.ino
INO
// 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  A0

Reviews & Ratings

0 reviews
5★
0
4★
0
3★
0
2★
0
1★
0

Loading reviews…