My Cart:

0 item(s) - £0.00
You have no items in your shopping cart.

0

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. As we have recently switched from a caster that fits to the chassis to a caster that fits through the chassis we have produced two sets of instructions. Ensure you select the correct version for your buggy as the fitting the caster step in the instructions happens in different places for each version.

  • Download the caster to chassis instructions here.
  • Download the caster through chassis instructions here.

 

Learn how to:

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

Parts List

bbc_microbit_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 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 (red, 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 two of the ‘T’ shape acrylic pieces, push one through the bottom of the board (start with the position shown in the image for Motor 1) 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 - Connecting The Motors To The Motor Driver Board

5604-line-following-buggy-step-3-870

Attach the Motor Driver Board to the top of the chassis using the M3 20mm Plastic Spacers and M3 6mm Machine Screws. Make sure the terminal blocks are facing the centre of the board.

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 4 - 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 5 - 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 6 - 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 7 - Solder The LDR's

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 8 - Solder The Red LED's

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 9 - Solder The Clear LED's

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 10 - 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 11 - 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

Note: The terminal block supplied should not be used.

 

Step 12 - Attach The Line Following Board To The Buggy

5604-line-following-buggy-step-12-1000

Placing the 4 x plastic Hex M-F Standoff’s 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 Standoff's. Feed through the four wires from the Line Following Board through the hole in the middle of the chassis of the buggy.

 

Step 13 - Connect The Wires To The Motor Driver Board

5604-line-following-buggy-step-13-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 14 - Attach The Battery Box

5604-line-following-buggy-step-14-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 15 - Attach The Caster

5604-line-following-buggy-step-15-870

Attach the caster to the rear of the buggy using 2 x 6mm M3 Machine Screws.

Note: If the caster is supplied with any additional spacers these are not required.

 

Step 16 - Test The Code

Download the code here: https://www.microbit.co.uk/lapexp.

Now, let’s try the code out! Click on the red button labelled Edit and you will be taken to the code. Press compile and after a few moments the code should appear as a download in your browser. If you plug your BBC microbit into a USB port it will show up as a storage device. Simply 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 LED’s 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. As we have recently switched from a caster that fits to the chassis to a caster that fits through the chassis we have produced two sets of instructions. Ensure you select the correct version for your buggy as the fitting the caster step in the instructions happens in different places for each version.

  • Download the caster to chassis instructions here.
  • Download the caster through chassis instructions here.
Resources
← Previous Post Next Post →

14 thoughts on “BBC micro:bit Line Following Buggy Build Instructions”

  • ian morton May 6, 2016 at 6:40 pm

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

    Reply
    • Mark Donnison May 10, 2016 at 12:31 pm

      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.

      Reply
  • BBC micro:bit - The Woolley Factor - Bluetooth BlogBluetooth Blog June 22, 2016 at 7:57 pm

    […] sell a nice buggy kit which is designed to follow lines on the ground. I reprogrammed it to respond to event messages […]

    Reply
    • Owen Brotherwood December 23, 2016 at 7:49 pm

      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

      Reply
      • Rish June 26, 2017 at 9:10 am

        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

        Reply
        • Mark Donnison July 5, 2017 at 12:21 pm

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

          Reply
  • Alex Clewett February 20, 2017 at 9:39 am

    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.

    Reply
    • Mark Donnison February 20, 2017 at 4:24 pm

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

      Reply
  • Alex Clewett February 20, 2017 at 9:45 am

    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?

    Reply
    • Mark Donnison February 20, 2017 at 4:56 pm

      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.

      Reply
  • F March 18, 2017 at 9:40 pm

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

    Reply
    • Mark Donnison March 23, 2017 at 3:19 pm

      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.

      Reply
  • Davide November 11, 2017 at 5:59 am

    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

    Reply
    • Mark Donnison November 13, 2017 at 1:13 pm

      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.

      Reply
Leave a Reply