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 componentsSend the robot to numbered destinations: each Bluetooth command runs a fixed route, then it reports that it has arrived. Instead of the driver holding a key down, one command starts a whole pre-programmed route. Each destination is a short list of moves, forward for so long, turn, forward again, and the robot works through it, then buzzes to say the delivery is complete. Because the robot is following a stored sequence rather than reacting moment to moment, this is a state machine: it is in one named state at a time, and the command chooses which.
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_41_mini_delivery_robot.inoVerify & upload in Electrolark#include <SoftwareSerial.h>
SoftwareSerial bt(2, 3);
int ENA = 9, IN1 = 4, IN2 = 5, IN3 = 6, IN4 = 7, ENB = 10;
int buzzer = 8;
int speedValue = 150;
void motors(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(int ms) { motors(HIGH, LOW, HIGH, LOW ); delay(ms); }
void turnLeft(int ms) { motors(LOW, HIGH, HIGH, LOW ); delay(ms); }
void turnRight(int ms){ motors(HIGH, LOW, LOW, HIGH); delay(ms); }
void stopBot() { motors(LOW, LOW, LOW, LOW); analogWrite(ENA, 0);
analogWrite(ENB, 0); }
void arrived()
{
stopBot();
for (int i = 0; i < 3; i++)
{
digitalWrite(buzzer, HIGH);
delay(150);
digitalWrite(buzzer, LOW);
delay(150);
}
bt.println("Delivered");
}
void setup()
{
pinMode(ENA, OUTPUT); pinMode(ENB, OUTPUT);
pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
pinMode(buzzer, OUTPUT);
bt.begin(9600);
Serial.begin(9600);
stopBot();
}
void loop()
{
if (!bt.available())
{
return;
}
char destination = bt.read();
Serial.println(destination);
if (destination == '1')
{
bt.println("Going to desk 1");
forward(1500);
arrived();
}
else if (destination == '2')
{
bt.println("Going to desk 2");
forward(1200);
turnRight(450);
forward(1000);
arrived();
}
else if (destination == '3')
{
bt.println("Going to desk 3");
forward(1200);
turnLeft(450);
forward(1000);
arrived();
}
else if (destination == 'H')
{
bt.println("Returning home");
turnRight(900);
forward(1600);
arrived();
}
else if (destination == 'S')
{
stopBot();
}
}
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.
The active buzzer has a + leg: it goes to the pin, the other to GND. Peel off the sticker on top if it has one.
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.
Instead of the driver holding a key down, one command starts a whole pre-programmed route. Each destination is a short list of moves, forward for so long, turn, forward again, and the robot works through it, then buzzes to say the delivery is complete. Because the robot is following a stored sequence rather than reacting moment to moment, this is a state machine: it is in one named state at a time, and the command chooses which.
Send 1 and the robot drives straight to desk 1, then buzzes three times. Send 2 or 3 and it takes a turn on the way. The phone receives Going to desk 2 and then Delivered.
Yes. It is project 41 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.
12 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), PCB Mounted Active Buzzer Module, 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), plus 2 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 1 hour 30 minutes. The build on this page has 8 steps.
No. This page has the complete, tested code (explorer_kit_41_mini_delivery_robot.ino).
About ₹1,434 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Bluetooth directional state machines; Encoding a route as a sequence of timed moves; Sending status messages back to the operator; Why timed routes drift and need re-tuning.
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.