MatchBot - a tiny line-following robot using the Raspberry Pi Zero
Posted by: Astro Designs at 21:41, December 3 2015.

Introducing the MatchBot - a Raspberry Pi 'Zero' powered line-following, proximity sensing robot stuffed into a matchbox...


MatchBot - A Raspberry Pi robot in a matchbox

How it started - With PiWars in full swing and seeing lots of PiWars activity on Twitter i just fancied a challenge of building something. Not to compete though, this was more of a personal challenge to make something small and do it quickly. With the PiZero just out, I wanted to see if I could be one of the first to create a super-small, line-following, proximity sensing robot based on the PiZero. As a spectator and a sponsor of PiWars, I already had my tickets booked so I'd hoped to build a pocket-sized robot in just time to take with me to PiWars.

I'd previously bought some small motors from Seeed Studio and some wheels from Pololu with a plan to create a small line-sensing robot based on the Raspberry Pi B+. I'd also recently bought a couple of the CamJam EduKit #3 as a Christmas present for each of our two girls...


MatchBot Wheels  MatchBot Motors

CamJam Kit parts

Some parts from the excellent CamJam EduKit #3


When the 'Zero came out that changed things instantly and by the end of the same day that the Zero was released I'd managed to complete the initial build, test run the motors and even get some of the first pictures on Twitter of MatchBot, made from a matchbox, the Seed Studio motors, the Pololu wheels amd the CamJam EduKit #3. Unfortunately I didn't have my PiZero at that time so I had to settle on a cardboard replica made from pictures I found on the internet (sincerest apologies to the Raspberry Pi guys for that!). The cardboard PiZero was super-glued to a header which was then plugged into the 4Tronix motor driver that came with the EduKit - just ensure it was all going to fit. So the first picture does show a cardboard replica. Thankfully this was quickly replaced with my real PiZero once I picked it up following a visit to the Cotswold Raspberry Jam on the 28th and MatchBot was running using the 'Zero and happily following a line taped to the dining room table by the end of the 30th. I have to give full credit to the guys who created the CamJam Edukit #3 for the bulk of the code. The line-following and proximity code came straight from their worksheets.

Another evening of tinkering and i'd got the proximity sensing function working nicely.

Some random pics of the construction...


MatchBot Power Supply

The Power supply was an off-the-shelf adjustable 'buck' converter that provides a nice 5V supply to the Pi from the 6V battery pack, leaving the 6V available to run the motors.


MatchBot Assembly

The motor driver was taken from the CamJam Edukit #3. It was modified slightly just to make it fit better. The connectors were removed and the wires were soldered directly to the board to save space. I also assembled the 5V-to-3.3V level shift resistors direct to the pins of the Pi header, again to save some space.


MatchBot Assembly

The motor driver sits directly on to of one of the motors so to prevent the motor from shorting out any connections on the base of the motor driver board, a couple of layers of 'Kapton' tape were stuck to the base of the motor driver.


And the final product & video... (click the photo to open up the video)


MatchBot Video


How to control it was next. I wanted to remove the USB adapter cable and the WiFi dongle and get it running the program from boot. Running a problem from boot was relatively easy but how to select which function to run? So i installed an LED and created a hand-wavey menu system using flashes from the LED to show which function was selected, waving your hand over the proximity sensors at various distances to select the function and then hold your finger or something reflective over the line-sensing photo-sensor to activate that function. Functions available are 5-flashes = Halt, 4-flashes = exit (to command-line), 3-flashes = Proximity, 2-flashes = line-follower, 1-flash = do nothing (out-of-range.). This seems to work very well and with the USB cable & wifo adapter now gone it's looking very small and almost pocket-sized.


Shrinking it down into the next sized matchbox down...


MatchBot - the next stage...