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 componentsStart and stop the robot by clapping, using a sound sensor as a one-bit voice command. The sound module's digital output pulses LOW whenever the noise crosses the level set by its onboard potentiometer. One clap can produce several of those pulses as the sound echoes, so the sketch ignores anything arriving within 400 ms of the last accepted clap. That guard is the difference between a robot that toggles once and one that flickers on and off. A single boolean holds the whole state of the machine: moving, or not.
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
LEDs from the kit's red, green, yellow and blue packs
220 ohm resistors: one in series with every LED segment
Sound sensor: its DO pin goes active when a clap or voice crosses the knob setting
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_38_voice_buzzer_robot.inoVerify & upload in Electrolarkint ENA = 9, IN1 = 4, IN2 = 5, IN3 = 6, IN4 = 7, ENB = 10;
int soundPin = 2;
int led = 8;
bool moving = false;
unsigned long lastClap = 0;
int speedValue = 150;
void motors(int l1, int l2, int r1, int r2, int power)
{
digitalWrite(IN1, l1); digitalWrite(IN2, l2);
digitalWrite(IN3, r1); digitalWrite(IN4, r2);
analogWrite(ENA, power);
analogWrite(ENB, power);
}
void setup()
{
pinMode(ENA, OUTPUT); pinMode(ENB, OUTPUT);
pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
pinMode(soundPin, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
Serial.println("Clap to start or stop");
}
void loop()
{
if (digitalRead(soundPin) == LOW)
{
if (millis() - lastClap > 400)
{
moving = !moving;
lastClap = millis();
Serial.print("Clap detected. Moving: ");
Serial.println(moving);
}
}
if (moving)
{
motors(HIGH, LOW, HIGH, LOW, speedValue);
digitalWrite(led, HIGH);
}
else
{
motors(LOW, LOW, LOW, LOW, 0);
digitalWrite(led, LOW);
}
}
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.
Turn it round: the long leg (anode) goes to the pin side through the 220 ohm resistor, the short leg to GND.
Turn the blue trim pot on the sound sensor slowly until its LED just goes off in a quiet room.
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 sound module's digital output pulses LOW whenever the noise crosses the level set by its onboard potentiometer. One clap can produce several of those pulses as the sound echoes, so the sketch ignores anything arriving within 400 ms of the last accepted clap. That guard is the difference between a robot that toggles once and one that flickers on and off. A single boolean holds the whole state of the machine: moving, or not.
Clap once: the LED lights and the robot drives forward. Clap again: it stops and the LED goes out. Serial Monitor logs each accepted clap.
Yes. It is project 38 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, Dupont Jumper Wires (40 pcs), Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), Generic LM393 Sound Detection Sensor Module – Digital Output, 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 1 hour. The build on this page has 8 steps.
No. This page has the complete, tested code (explorer_kit_38_voice_buzzer_robot.ino).
About ₹1,241 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Sound triggers and basic movement; Toggling state with the ! operator; Ignoring repeat triggers with millis(); Why echoes need a guard window.
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.