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 componentsThe OpenMV Cam H7 is a camera with a fast microcontroller that runs MicroPython vision code on the camera itself. It can find faces using a built-in Haar cascade. The Servo Shield adds a PCA9685 servo driver on I2C. Each frame, the script finds the largest face and nudges the pan and tilt servos towards it, so the camera keeps you centred.
Tell people when a camera is recording or tracking them.
Tick anything you already have and the total updates.
OpenMV Servo Shield (PCA9685)
Follow the colours: red is power, dark grey is ground, blue is a signal.
5 V USB supply of 2 A or more for the camera and servos.
face_tracker.pyimport sensor, image, time
from machine import I2C, Pin
from servo import Servos
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.HQVGA)
face = image.HaarCascade("frontalface", stages=25)
i2c = I2C(sda=Pin('P5'), scl=Pin('P4'))
servo = Servos(i2c, address=0x40, freq=50, min_us=650, max_us=2800, degrees=180)
pan, tilt, GAIN = 90, 90, 0.05
servo.position(0, pan); servo.position(1, tilt)
while True:
img = sensor.snapshot()
faces = img.find_features(face, threshold=0.75, scale_factor=1.25)
if faces:
x, y, w, h = max(faces, key=lambda f: f[2] * f[3])
img.draw_rectangle(x, y, w, h)
pan -= (x + w / 2 - img.width() / 2) * GAIN
tilt += (y + h / 2 - img.height() / 2) * GAIN
pan = min(170, max(10, pan)); tilt = min(150, max(30, tilt))
servo.position(0, int(pan)); servo.position(1, int(tilt))
Flip the sign in the pan or tilt line.
Lower GAIN.
Light the face from the front; Haar cascades need a clear frontal view.
Only to load the script; then it runs alone from USB power.
Yes, use find_blobs with a colour threshold instead of find_features.
The PCA9685 makes steady servo pulses so the camera's processor can focus on vision.
5 parts: OpenMV Cam H7 Machine Vision Camera Module, OpenMV Servo Shield – PCA9685 8-Channel PWM Controller, 2 × TowerPro SG90 9g Micro Servo (180°), Pan-Tilt Bracket Kit for SG90 / MG90S Servos and Official Raspberry Pi 4 USB-C Power Supply – 15.3W. On this page you can tick the parts you already have and add only the rest to your cart.
It is a advanced project and takes about 3 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (face_tracker.py).
About ₹10,345 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Running vision code on a microcontroller; Driving servos through a PCA9685; A simple proportional tracking loop.
Tell people when a camera is recording or tracking them.
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.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.