Arduino Robot Car: Complete 2WD Build Guide
The two-wheel-drive robot car is the best first robot you can build: cheap, forgiving, and the finished chassis becomes the platform for the line follower and obstacle avoider projects. This guide takes you from a bag of parts to a car that drives a programmed route, and explains why each wire goes where it goes.
If you have never uploaded an Arduino sketch, do the 45-minute Arduino basics guide first — this build assumes it.
How the robot works
An Arduino pin can supply about 20–40 mA; a small gear motor stalls at over 1 A. The motor driver bridges that gap: the Arduino sends tiny logic signals, and the driver switches battery current into the motors. Steering is differential — there is no steering wheel; you turn by running one side faster than the other, and spin on the spot by running the sides in opposite directions.
Parts list (BOM)
| Part | Notes | Indicative price (India) |
|---|---|---|
| 2WD acrylic chassis kit | Includes 2 TT gear motors, wheels, castor, screws | ₹300–600 |
| Arduino Uno R3 (compatible) | Plus USB cable | ₹400–800 |
| L298N motor driver module | Dual H-bridge with 5 V regulator | ₹90–180 |
| Battery holder: 6×AA (or 2×18650 + holder) | See the power section before choosing | ₹60–450 |
| Jumper wires (M–F and M–M) | 20 of each | ₹100–200 |
| Rocker/slide switch | Between battery and driver — worth it | ₹15–40 |
| Small cable ties / double-sided tape | Cable management and mounting | ₹40–80 |
Prices shown are indicative online street prices in India as of mid-2026. They vary by seller and stock — treat them as a budgeting guide, not a quote.
Total: roughly ₹1,100–1,900 depending on what you already own. Every part is reused in the follow-on projects.
Assemble the chassis
- Peel the protective paper off the acrylic plate (yes, it comes off — the plate is clear or coloured underneath).
- Bolt the two TT gear motors to the rear slots using the included brackets, motor shafts pointing outward. Solder or firmly crimp a red and black wire to each motor’s terminals before mounting if they aren’t pre-wired.
- Fit the castor wheel at the front centre with its spacers.
- Push the wheels onto the motor shafts.
- Mount the Arduino and L298N on top with the included standoffs or double-sided tape, and the battery holder wherever it balances the car (usually the middle).
Wire the L298N motor driver
Remove nothing from the L298N except, later, the ENA/ENB jumpers. Wire it exactly as follows (this pinout is used consistently across all Hobby Robots guides, and deliberately leaves pins 3, 9, 10, 11 free for servos and sensors):
| L298N terminal | Connects to | Purpose |
|---|---|---|
| OUT1, OUT2 | Left motor wires | Left motor power |
| OUT3, OUT4 | Right motor wires | Right motor power |
| 12V (VIN) | Battery +, through the switch | Motor supply (6–9 V here) |
| GND | Battery − and Arduino GND | Common ground — required |
| 5V | Arduino 5V pin | Powers the Uno from the driver’s regulator |
| ENA | Arduino D5 (PWM) | Left speed — remove jumper first |
| IN1 / IN2 | Arduino D7 / D8 | Left direction |
| IN3 / IN4 | Arduino D4 / D2 | Right direction |
| ENB | Arduino D6 (PWM) | Right speed — remove jumper first |
Whenever two boards or modules talk to each other, their GND pins must be connected. A missing common ground is the single most frequent cause of “my sensor reads garbage” problems.
With the small on-board jumper next to the 12V terminal fitted, the module generates 5 V that can power your Arduino via its 5V pin (as in the table). This is fine for battery input up to ~12 V. Never feed the L298N’s 5V terminal from the Arduino at the same time as USB, and unplug the battery’s red wire whenever the USB cable is connected — or the two supplies will fight.
Powering it properly
Under-powered motors are the #1 rookie frustration. Rules of thumb:
- 6×AA NiMH or alkaline (7.2–9 V) — simplest and safest; decent torque. Avoid a single 9 V PP3 block: it cannot deliver motor current and the car will crawl or reset.
- 2×18650 Li-ion (7.4 V nominal) — best runtime, but use protected cells, a proper holder, and a charger designed for Li-ion. Skip this if the builder is a young student.
- The L298N is an old bipolar design and drops roughly 2 V internally, so your motors see about 2 V less than the battery. That is why 6 V-rated TT motors pair fine with an 8–9 V pack — and why the TB6612 upgrade exists.
First test: spin the wheels
Prop the chassis on a box so the wheels are in the air, unplug the battery, connect USB, and upload:
// Hobby Robots — motor spin test (no wheels on the ground yet!)
const int ENA = 5; // left speed (PWM)
const int IN1 = 7; // left direction
const int IN2 = 8;
const int ENB = 6; // right speed (PWM)
const int IN3 = 4; // right direction
const int IN4 = 2;
void setup() {
pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); // left forward
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); // right forward
analogWrite(ENA, 180);
analogWrite(ENB, 180);
delay(2000); // spin 2 s
analogWrite(ENA, 0);
analogWrite(ENB, 0); // stop
}
void loop() {}Disconnect USB, connect the battery, flip the switch: both wheels should spin forward for two seconds. If a wheel spins backward, swap that motor’s two wires at the OUT terminals (or swap its IN pin values in code). Fix this now — every later guide assumes HIGH/LOW on IN1/IN2 means forward.
The reusable drive code
Rather than sprinkling digitalWrite calls everywhere, wrap movement in one function. This drive(left, right) takes speeds from −255 to 255 and is the foundation the line-follower and obstacle-avoider guides build on:
// Hobby Robots — reusable 2WD drive code
// Wiring: ENA=5 IN1=7 IN2=8 (left) | ENB=6 IN3=4 IN4=2 (right)
const int ENA = 5, IN1 = 7, IN2 = 8;
const int ENB = 6, IN3 = 4, IN4 = 2;
// left/right: -255 (full reverse) .. 255 (full forward)
void drive(int left, int right) {
digitalWrite(IN1, left >= 0 ? HIGH : LOW);
digitalWrite(IN2, left >= 0 ? LOW : HIGH);
analogWrite (ENA, min(abs(left), 255));
digitalWrite(IN3, right >= 0 ? HIGH : LOW);
digitalWrite(IN4, right >= 0 ? LOW : HIGH);
analogWrite (ENB, min(abs(right), 255));
}
void stopMotors() { drive(0, 0); }
void setup() {
pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
stopMotors();
delay(3000); // time to put the car down and step back
drive(200, 200); delay(1500); // forward
drive(-180, 180); delay(600); // spin left on the spot
drive(200, 200); delay(1500); // forward again
drive(180, -180); delay(600); // spin right
stopMotors();
}
void loop() {}It gives you time to unplug USB, set the car on the floor, and step back before it moves. Cheap insurance for your laptop’s USB port.
Troubleshooting
| Symptom | Most likely cause | Fix |
|---|---|---|
| Nothing moves, driver LED off | Battery/switch wiring, dead batteries | Check pack voltage at the 12V/GND terminals with a multimeter |
| Arduino resets when motors start | Weak battery (often a 9 V block) | Use 6×AA or 2×18650; check connections |
| One wheel doesn’t spin | Loose OUT terminal or broken motor wire | Tug-test each screw terminal; swap motors to isolate |
| Wheel spins the wrong way | Motor polarity | Swap that motor’s two wires at OUT |
| Motors whine but barely move | ENA/ENB jumpers removed but pins not driven, or PWM too low | Drive ENA/ENB from D5/D6, use speeds ≥150 to start |
| Works on USB, dead on battery | Missing driver-GND↔Arduino-GND link or 5V jumper off | Re-check the ground and the 5 V regulator jumper |