Make a Grove Zero Line Follower Robot

Difficulty
Easy
Steps
8

The Grove Zero bit kit allows you to create a small but cool car robot in just a few seconds. 

In this guide, we will create a line-following robot using the BBC micro:bit and Grove Zero bit kit. 

After completing this guide, you will have delved into the basics of programming logic and in the process, learned how to make a robot that follows lines.

Parts Used in This Guide

BBC micro:bit
LB-00181

Buy

Buy

Step 1  Add the Grove Zero - BitKit Extension

  • Open up the MakeCode Editor. 
  • Click on 'New Project'.
  • Before we can program the Grove Zero Bit kit micro:car, we'll need to add the extension package for it in MakeCode. So click on the 'Advanced' tab which will expand, then click on 'Extensions' tab. 
  • Type 'zero' in the search field.
  • Click on 'grove-zero-for-microbit' package.

Step 2  If statement

  • Click on 'BitKit' tab to find a 'Color Line Follower see line at middle' block. Add this to 'If ... then ...' in the 'forever' block.
    • The if statement is used as such: if "this happens" then "do this"
  • Add a 'Chassis go forward at slow speed' block in the "if ... then ..." condition.

Step 3  Determining the line position

Now, we need to add a statement for the 'if' to follow,

  • Add a "Chassis go ... at ... speed' from BitKit tab to complete the 'if ... then ...' logic control block.

Step 4  Moving left

Next, we need to sense when our robot needs to move left or right. It is a simple process and follows our layout above. However, we need to add another 'if', to do this:

  • Click on the white cross icon at the bottom of the 'if ... then ...' statement. Click it again.
  • Delete the 'else' statement by clicking on the white minus icon. 

We can do the same as the step above but replacing these values:

  • The line position variable can change from 'middle' to 'left';
  • The direction variable needs to be changed from 'forward' to 'left' at speed 'medium'

Step 5  Moving right

Moving right is similar as the step above.

  • Create a new 'else if' section;
  • Add a 'Color Line Follower see line at ...' block 
  • Set its value to 'right'  
  • Add a 'Chassis go ... at ... speed' block. 
  • Set its values as 'right' and 'medium'

Step 6  Loosing the line!

Now, what happens if our little robot loses the line? What is it going to do? This is where you tell it what to do!

  • Add the following blocks as shown below.
  • Most importantly, add the last 'else if' statement. 
  • Next, add a 'Color Line Follower see line at ... ' block, this time changing its value to 'lost'.
  • Add a 'chassis go ... at ... speed' block, and change its value to 'counter-clockwise' and 'fast.

Step 7  Programming the micro:bit

  • Download the hex file and copy across to the micro:bit
  • Note: To copy the files across, the micro:bit must be plugged in, not the micro:car board. The USB port of the micro:car is only used to charge the battery and it is not for programming.

Step 8  Building the grove zero with the line follower

The final step is to build the Grove Zero micro:car. 

  • Begin by getting the motor base (the one with the tracks) and connecting the battery/micro:bit mount on-top.
  • Note that this piece is dependent on the orientation. 
  • The white part of the board must face the front of the robot (the direction of the arrows on the side are pointing). 
  • Without the correct orientation, the robot will not do anything!
  • The battery is located underneath the board and is surrounded by black plastic.
  • Next, place the micro:bit into the slot.
  • Add the blue line follower module to the front of the bot, making sure that it is also on the lowest connector.
  • Lastly, turn on the power switch on the left hand side of the mounting board

We have completed our robot. Place it on a line and watch it go!