All projects

MARV line-following robot

An autonomous robot that reads the track under its nose with a strobing RGB LED and phototransistors, tells five surfaces apart, and follows a chosen line without getting lost where lines cross.

Course
EMK310, University of Pretoria
Controller
PIC18F45K22
Firmware
Hand-written assembly
Role
Designer and builder
MARV following a line on the practice track

Overview

A line follower only needs to know one thing: what colour is under the nose right now. MARV answers that question with light.

An RGB LED under the sensor head flashes red, then green, then blue onto the track. Phototransistors pick up how much of each flash the surface reflects, and the PIC18's ADC samples them once per flash. Every surface leaves its own three-number signature: white reflects all three, black almost none, and each coloured line reflects mostly its own colour.

A calibration routine records the signature of white, black, red, green and blue on the real track, and sets the decision thresholds between them. From then on the firmware classifies every reading, and steers the two driven wheels to keep the chosen line centred.

5surfaces told apart
R · G · Bstrobes per reading
PIC18hand-written assembly
2 + 1driven wheels and a trolley caster

See it working

A 30-second 3D film of MARV, modelled from the real build, animated and rendered in Blender.

How it works

Light out, light back, one ADC sample per flash, then a decision and a steering correction, over and over.

Signal chain: the RGB LED strobes onto the track, phototransistors read the reflection, the PIC18 ADC samples each flash, the firmware classifies the surface and drives the two wheel motors. RGB LEDstrobes R, G, B Track surfacereflects its colour Phototransistorslight to voltage PIC18 ADCone sample per flash Classifysignature vs thresholds SteeringPWM to the two gearmotors Strobe timingLED colour set before each ADC sample LED select

Try the calibration

Run the calibration to store each surface's signature, then place the sensor over any surface and watch it strobe, sample and decide. The levels are illustrative, the method is MARV's.

Place the sensor

Pick the surface under MARV's nose.

Not calibrated yet. Readings still work, but nothing can be classified.

LED off
Classified as
Waiting for calibration

Ticks mark the stored signature of each surface on that channel. MARV picks the surface whose stored signature is closest to all three readings at once.

Results

It worked. MARV followed every colour on the practice track and held its line through crossings.

  • All five surfaces classified on the real track after calibration: white, black, red, green and blue.
  • Followed each coloured line from start to finish, including the black, red, green and blue routes.
  • No lost lines at crossings. Where coloured lines crossed over each other, MARV kept to the colour it was following instead of switching to the new one.

3D model

MARV rebuilt in Blender from the photos of the final build, for the film and these stills.

Front: yoke, loom and sensor housing
Side: front drive wheels, trolley caster at the rear
Rear: 9 V battery cradle and jumpers
Head on: sensor housing and wing plates

Photos

The final build, and the earlier prototype it grew out of.

Final build
Side view
Head on
Sensor head over the track
Earlier prototype
Prototype on the development board
Early build on the bench
On the practice track