Christmas Information: Kitronik will be closing 24th Dec December 2024, reopening on 2nd of January 2025. See our delivery schedule for more information.

BBC micro:bit Line Following Buggy Build Instructions
In January we were one of the three partners of the BBC showcasing the BBC microbit at the BETT Show 2016. Our BBC microbit controlled line following buggy was a great draw and many of you have asked how to build your own. Now you can, thanks to this easy to follow step by step guide and our even easier kit! bbc_microbit_line_following_buggy_top_870 Below you'll find complete step by step build instructions, We'll guide you through building our BBC microbit controlled Line Following Buggy. The buggy uses two light dependent resistors to control a line following board on the bottom of the chassis to 'follow' black lines. Two LEDs shine light from underneath the buggy down onto the floor and a pair of LDRs measure how much light is reflected. When the sensor is moved over a black line the level of reflected light decreases and the sensor sends a signal to the BBC microbit through the motor driver board. The BBC microbit then uses that information to steer back toward the line. It does this by switching off either the left motor to turn left or the right motor to turn right.  

Download the PDF of this Guide:

We've also produced a PDF version of this guide that you can download below.
  • Download the instructions here.

Learn how to:

  • Build a line following buggy.
  • Power motors with the Motor Driver Board for the BBC microbit.

Parts List

line-following-buggy-parts-870 The buggy is simple to build, all you need is a BBC microbit and our Line Following Buggy Kit. Alternatively, you can build one from scratch with the following parts:

You will also require the following equipment:

  • Chassis Laser Cut file (.dxf).
  • A small flat head screwdriver.
  • A wire stripper.
  • A soldering iron and some solder.
  • A pair of pliers.
  • A Phillips screwdriver.
  • A computer with a spare USB port and internet access.
  • A USB to micro USB cable.
  • Black insulation tape.
  • A BBC microbit.

Let's Get Started!

If you have the Line Following buggy kit you can proceed directly to step 1. If you've sourced all of the parts yourself, before proceeding to Step 1, you will need to cut the chassis from the Perspex sheet using the 'Chassis Laser Cut file' (see above) using a laser cutter.

Step 1 - Solder The Wires Onto The Two Motors

5604-line-following-buggy-step-1-870 Using the four pieces of wire (white, green, blue and black) supplied with the chassis, strip and solder one end of each wire to each motor terminal (a small copper contact protruding from the end of the motor). This is done by putting the exposed wire through the hole on the contact and soldering into place. The colours should be as shown in the picture which are:
  • Wire 1 on Motor 1 = White.
  • Wire 2 on Motor 1 = Green.
  • Wire 1 on Motor 2 = Blue.
  • Wire 2 on Motor 2 = Black.

Step 2 - Securing The Motors

5604-line-following-buggy-step-2-870

Take the protective backing off the main chassis. Take two of the ‘T’ shape acrylic pieces, push one through the bottom of the board (the top of the board is engraved with the word top) and align the other one up the notch in the edge of the body of the buggy. Place the Motor 1 (green and white wires) between the two pieces with the motor terminals pointing toward the rounded corners of the buggy and the axle pointing outwards. Ensure that the motor is placed on the top side of the board. Push a M3 30mm Pozi Pan Machine Screw through the holes in the 'T' pieces and motor to secure it in place, and then fasten it with the M3 Full Width nut. Repeat this for Motor 2 (blue and black) on the opposite side of the buggy, then push the wheels onto the motor axles.

Step 3 - Attach the caster

line-following-buggy-step-3-attach-caster-870 To attach the caster to the buggy, on the side marked top, place the provided acrylic spacer so that it lines up with the caster holes to the rear of the board. Place the caster so that the ball pokes through to the underside of the board. Fix the caster in place using the 2 x 12mm M3 Machine Screws and 2 x M3 Full Width nuts.

Step 4 - Attach the Motor Driver Board

line-following-buggy-step-4-attach-motor-standoffs-870 Attach the plastic spacers using four of the 6mm screws from underneath as shown above. line-following-buggy-step-4-attach-motor-board-870 Attach the Motor Driver Board to the top of the M3 20mm Plastic Spacers using the M3 6mm Machine Screws. Make sure the terminal blocks are facing the centre of the board.

Step 5 - Connecting The Motors To The Motor Driver Board

line-following-buggy-step-4-attach-motor-wires-870

Take the wires from the motors and connect them to the terminal blocks on the motor driver board in the following configuration:
  • Wire 1 on Motor 1 (White) goes into the 'P12' terminal.
  • Wire 2 on Motor 1 (Green) goes into the 'P8' terminal.
  • Wire 1 on Motor 2 (Blue) goes into the 'P0' terminal.
  • Wire 2 on Motor 2 (Black) goes into the 'P16' terminal.
The next task is to build the line following PCB.

Step 6 - Place Resistors

5604-line-following-buggy-step-4-1-150

Start with the six resistors: The text on the PCB shows where R1, R2 etc go. Ensure that you put the resistors in the right place.
PCB Ref Value Colour Bands
R1, R2, R8 & R9 470Ω Yellow, Purple, Brown
R3, R4 2.2kΩ Red, Red, Red

 Step 7 - Solder The IC Holder.

5604-line-following-buggy-step-5-150 Solder the Integrated Circuit (IC) holder in to U1. When putting this into the board, be sure to get it the right way around. The notch on the top of the IC holder should line up with the notch on the lines marked on the PCB.

Step 8 - Solder The Potentiometer

5604-line-following-buggy-step-6-150 Solder R7, the variable potentiometer, in to the PCB where it is labelled R7.

Step 9 - Solder The LDRs

5604-line-following-buggy-step-7-150 Solder the two Light Dependant Resistors (or LDR's for short) into the board where it is marked R5 & R6.

Step 10 - Solder The Red LEDs

5604-line-following-buggy-step-8-870

The two red LEDs are designed to point out of the back of the board so you can see them when the board is attached to the buggy. The leads of the red LED's need to be bent 90° before they are soldered in to the board where it is labelled LED3 and LED4. The flat edge of the LED matches up with the LED outline on the PCB. Make sure the LEDs are soldered in the right way around.

Step 11 - Solder The Clear LEDs

5604-line-following-buggy-step-9-870

Solder in the two clear LEDs (LED1 and LED2) directly into the board. These LEDs don't need to be bent but again make sure the flat edge of the LED matches up with the LED outline on the PCB.

Step 12 - Insert The IC

Put the LM358 op amp IC into the holder labelled U1 ensuring the notch on the chip lines up with the notch on the PCB outline.

Step 13 - Line Following Connecting Wires

5604-line-following-buggy-step-11-870

Strip both ends of the blue, red, yellow and black wires and then solder one end of each the directly to the PCB as follows:
  • Out 1 = Blue
  • Out 2 = Yellow
  • +v = Red
  • 0v = Black

Step 14 - Attach The Line Following Board To The Buggy

line-following-buggy-step-13-attach-line-following-board-870

Placing the 4 x plastic Hex M-F Standoffs between the chassis and the line following board, attach the line following board to the bottom of the chassis with the red LEDs pointing out from under the front of the buggy. Use 4 x M3 screws to fix the line following board to the Standoffs and 4 x M3 Full Width Nuts to secure the chassis to the Standoffs. Feed through the four wires from the Line Following Board through the hole in the middle of the chassis of the buggy.

Step 15 - Connect The Wires To The Motor Driver Board

line-following-buggy-step-14-connect-wires-to-motor-driver-870

Connect the wires from the Line Following Board into the terminals on the Motor Driver Board for the BBC microbit as follows:
  • 'Out 1' (Blue) goes into 'INPUT2 - P2' terminal.
  • 'Out 2' (Yellow) goes into 'INPUT1 - P1' terminal.
  • '+v' (Red) goes into 'INPUT1 - 3V' terminal.
  • '0v' (Black) goes into 'GND' terminal.

Step 16 - Attach The Battery Box

line-following-buggy-step-15-connect-wires-to-motor-driver-870

Using the sticky pad, attach the battery pack to the top of the buggy chassis with the switch poking through the rectangular cut-out. Attach the red and black wires into the terminal on the Motor Driver Board for the BBC microbit labelled 'POWER'. Put the black wire in the left hand side of the terminal labelled 'BLACK' and the red wire in the right hand side of the terminal labelled 'RED'.

Step 17 - Test The Code

Download the code here: https://resources.kitronik.co.uk/zip/microbit-kitronik-line-following-buggy.zip. Now, let’s try the code out! Plug your BBC microbit into a USB port and it will show up as a storage device. Simply unzip, then drag and drop the .hex file you just downloaded onto the BBC microbit. The file might not show up on the BBC microbit in the file explorer but it is there! Once the file has been transferred (the light on the BBC microbit will stop blinking rapidly) remove the BBC microbit from your computer.

Step 17 - Test The Setup

On a white board or surface mark out an oval or similar shape using black insulation tape. Make sure the track is quite thick (roughly 2cms). Or alternatively draw the line on a large piece of paper using a black marker pen.

Step 18 - Try It Out!

bbc_microbit_powered crane_step_6_870

Insert your coded BBC microbit into the connector on the Motor Driver Board for the BBC microbit (it can be inserted either way around) and switch on the buggy (with batteries in) using the on/off switch on the bottom. Your buggy should now be working. When one of the sensors on the Line Following Board passes over the black line it will cause the buggy to turn back towards the line. The red LED’s on the Line Following Board light up when the corresponding sensor passes over the black line and can be used for visual feedback when developing and testing your own code. Note: R7 on the Line Following board is used to adjust the sensitivity of the LDR sensors. It is adjusted by turning the trimmer dial with a small flat head screwdriver. Try starting with R7 in the central position and then adjust it if needed.

Troubleshooting Guide

If the buggy doesn’t work as expected then check the following:
  • Check that the motor wires have been connected to the Motor Driver board as specified.
  • Check that the batteries are not flat.
  • Check the two power wires are connected the correct way around.
  • Check the wiring between the Motor Driver board and the Line Following board has been made as specified.
Check the bottom of the Line Following board to ensure that:
  • All holes except the 4 large 3 mm mounting holes in corners are filled with the lead of a component.
  • All these leads are soldered.
  • Pins next to each other are not soldered together.
Check the top of the Line Following board to ensure that:
  • The notch on the IC holder / IC matches the outline on the PCB.
  • The colour bands on R3 and R4 are red, red, red.
  • The flat edge on all four LEDs matches the corresponding outline on the PCB.

Download the PDF of this Guide:

We've also produced a PDF version of this guide that you can download below.
  • Download the caster through chassis instructions here.

16 comments

BBC

BBC

Micro:bit is the best. YAY

Mark Donnison

Mark Donnison

Hi David, I'm sorry that you are having problems with the motor driver board. Please drop support@kitronik.co.uk an email with the info you provided in your post and they can hopefully get you up and running quickly.

David McKibben

David McKibben

just got my son this for X-mas. unfortunately looks like a problem with the driver board. The Motor2 output is zero regadless of what we program…I've checked both motors and they both work if plugged into Motor1 terminals, but when we try to connect via Motor2 terminals then nothing…any ideas??

Mark Donnison

Mark Donnison

Hi Davide, sorry to hear that you are having issues with the line following buggy. If you drop a mail to support@kitronik.co.uk the support team can help you trouble shoot the issue. They may ask for photos of the board, so it might be an idea to get a couple taken just in case.

Davide

Davide

I realized that I have the caster through chassis model, so I corrected how I attached the caster (BTW, it might be helpful to underline the difference in the web version of the instructions as well). Now both sensors work more consistently. If I test them while preventing the buggy from moving forward, and I shift the buggy left/right so that the LDRs are above the white or black colors, everything works as expected. When the LDRs are both on the black line, both red LEDs are on and both wheels spin. When the left sensor is on the white background, the left LED and the right wheel turn off. When the right sensor is on white, the right LED and the left wheel turn off. When both sensors are on white, both LEDs are off, and both wheels spin. However, when I leave the buggy so that it moves forward, it doesn't follow the black line. Maybe it manages to do a couple of bends, but then it goes astray. I've tried all the values for the trimmer, but didn't find a solution. Regards, Davide

Mark Donnison

Mark Donnison

Hi Rishabh, we are currently looking into producing an add on for the :MOVE mini to add this functionality. Watch this space.

Rish

Rish

Hi Owen, I was wondering if you have an progress on adding the utrasonic sensor to this model? I'd be very interested in knowing more :D Rishabh

Mark Donnison

Mark Donnison

Hi, remove the solder from both and then re-solder each joint. If you noticed before you powered the circuit then you should be fine.

F

F

Hi, I accidently soldiered two of the legs of the IC holder together (one soldier bump). What do I do? :/

Mark Donnison

Mark Donnison

Hi Alex, if I were given the board the check without any supporting information other than that it doesn't work, I would do the following. If the board is detecting the line and the LED comes on and off correctly I would assume that there was something wrong between the LDR/LED and the motors. First I would try adjusting the sensitivity via the variable resistor, next I would assume I might have a possible dodgy solder joint and resolder the appropriate joints. If that didn't fix the issue I would look to the line follower connections to the motor driver board and make sure they were sound. We know the code works so if everything else has been thoroughly checked, there is a slim possibility that there is an issue with the motor driver board. The motor driver boards are pretty robust and are individually tested so I would be more inclined to think it was something else. Let me know how you get on with the above and if you still have a problem, let us know and we'll see what we can do for you to get you up and running.

Mark Donnison

Mark Donnison

Hi Alex, thanks for the feedback. It's now on my todo list.

Alex Clewett

Alex Clewett

The left and right LDRs seem to be responding differently i.e. the left one seems to detect the line every time but the right often misses or at least you can see the red led come on indicating that the line was detected but the buggy still does not turn to stay on the line. I am using the hex file as indicated in the instructions. I've checked that the board is constructed correctly, all soldering is sound etc. Any ideas what is going on and how to solve?

Alex Clewett

Alex Clewett

Hi, just some feedback about the 2 different sets of instructions. It may be helpful to include a picture of the 'through chassis' caster and say 'if your caster looks like this follow these instructions' as it is easily missed. Just a thought.

Owen Brotherwood

Owen Brotherwood

May I use photo's from here and there to document an Open Source project where the buggy is equipped with an ultrasonic detector? The kids and I will be playing with a couple of buggies over Xmas but some work needed to get to another level of buggy play === github and some help from micro:bit slack with hw pin issues Br Owen

Mark Donnison

Mark Donnison

Hi Ian, That's a good question. If the buggy is just following a line then there should be no problem. If you want to use the buggy to just drive in a straight line without following a straight line, the easiest way to even out the motors without using any extra parts is by using code to turn the faster motor on and off rapidly. It will take a little trial and error to get right but you could try turning the motor off for 5 milliseconds in every 100 milliseconds as a starting point and adjust from there. I hope this helps.

ian morton

ian morton

If the motors don't have exactly equal power, what is the best way to adjust the voltage to get straight movement?

Leave a comment

All comments are moderated before being published