Line follower robot with L298N and TCRT5000
The classic robotics starter: a two-wheeled car that tracks a black line on its own.
Shop by category
Shop all componentsDrive a two-motor chassis from your phone, forward, back, left, right and stop, over a Bluetooth link. The L298N is an H-bridge: two transistor pairs per motor that let current flow either way, which is what makes reverse possible. IN1/IN2 set the direction of the left motor and IN3/IN4 the right; ENA and ENB take a PWM value that sets the speed. Turning is done by driving the two sides in opposite directions, which spins the car on the spot. Every phone command is a single letter, so the whole protocol fits in a switch-like chain of ifs.
Switch the battery holder off before you change any wiring, and lift the wheels off the table for the first test.
Charge 18650 cells only in a proper Li-ion charger and never short the holder's wires.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Explorer Kit project
Male-to-female and female-to-female leads for the modules
HC-05 Bluetooth module: a serial link to your phone
1k and 2.2k resistors: drop the Nano's 5V TX signal to the 3.3V the HC-05 RXD pin expects
2WD chassis with two gear motors, wheels and a caster
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
Motors run from the 2 x 18650 pack (7.4V) through the L298N. The USB cable powers the Nano while you test; unplugged, the L298N's 5V output powers it.
explorer_kit_34_bluetooth_car.inoVerify & upload in Electrolark#include <SoftwareSerial.h>
SoftwareSerial bt(2, 3); // RX, TX
int ENA = 9;
int IN1 = 4;
int IN2 = 5;
int IN3 = 6;
int IN4 = 7;
int ENB = 10;
int speedValue = 180;
void drive(int l1, int l2, int r1, int r2)
{
digitalWrite(IN1, l1);
digitalWrite(IN2, l2);
digitalWrite(IN3, r1);
digitalWrite(IN4, r2);
analogWrite(ENA, speedValue);
analogWrite(ENB, speedValue);
}
void forward() { drive(HIGH, LOW, HIGH, LOW ); }
void backward() { drive(LOW, HIGH, LOW, HIGH); }
void turnLeft() { drive(LOW, HIGH, HIGH, LOW ); }
void turnRight(){ drive(HIGH, LOW, LOW, HIGH); }
void stopCar()
{
drive(LOW, LOW, LOW, LOW);
analogWrite(ENA, 0);
analogWrite(ENB, 0);
}
void setup()
{
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
bt.begin(9600);
Serial.begin(9600);
stopCar();
}
void loop()
{
if (!bt.available())
{
return;
}
char command = bt.read();
Serial.println(command);
if (command == 'F') forward();
else if (command == 'B') backward();
else if (command == 'L') turnLeft();
else if (command == 'R') turnRight();
else if (command == 'S') stopCar();
else if (command == '+') speedValue = min(speedValue + 25, 255);
else if (command == '-') speedValue = max(speedValue - 25, 80);
}
Use the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
Pair with the HC-05 using PIN 1234 (or 0000), then connect in a Bluetooth serial terminal app. Unplug TXD and RXD while uploading.
Switch the battery holder on, check +12V and GND on the L298N, take the ENA and ENB jumper caps off, and make sure battery GND joins Nano GND.
The L298N is an H-bridge: two transistor pairs per motor that let current flow either way, which is what makes reverse possible. IN1/IN2 set the direction of the left motor and IN3/IN4 the right; ENA and ENB take a PWM value that sets the speed. Turning is done by driving the two sides in opposite directions, which spins the car on the spot. Every phone command is a single letter, so the whole protocol fits in a switch-like chain of ifs.
Send F and the car drives forward. Send L or R and it spins on the spot. Send S and it stops.
Yes. It is project 34 of 61 in the Geekobot Explorer Kit, in level 7 (Robotics and motion). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
11 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), HC-05 6-Pin Bluetooth Serial Module with Button, Carbon Film Resistor 1/4W 5% (Pack of 10), 2WD Smart Robot Car Chassis Kit, L298N Dual H-Bridge Motor Driver Module, Arduino Nano IO Expansion Shield (328P Compatible), 18650 Battery Holder, plus 1 more. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 7 steps.
No. This page has the complete, tested code (explorer_kit_34_bluetooth_car.ino).
About ₹1,396 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Motor drivers and H-bridge direction control; Serial commands as a control protocol; Writing small helper functions for readability; Setting motor speed with PWM.
Switch the battery holder off before you change any wiring, and lift the wheels off the table for the first test. Charge 18650 cells only in a proper Li-ion charger and never short the holder's wires.
The classic robotics starter: a two-wheeled car that tracks a black line on its own.
A robot that looks left and right with its ultrasonic "head" and picks the clearest way.
Roams a tabletop without ever driving off the edge.
Drive a 4WD car from your Android phone over Bluetooth.
Learning project. Check every circuit and the datasheet of each part before you power it up.