Make a Grove Zero Line Follower Robot


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



Step 1  If statement

Logic is used in programming to allow our machine to make decisions, at the very core it is an 'if' statement. The if statement is used as such: 

if "this happens" then "do this"

  • Find the 'if' 'then' logic block within the 'Logic category' (Note: not the if, then, else block) and place within the forever loop.

Step 2  Determining the line position

Now, we need to add a statement (known as a trigger) for the 'if' to follow,

  • Add the block 'line position ... was triggered' (which is found in the sensor category, under 'more') next to the 'if' and set the variable to 'middle'
    • This means if the line position is in the middle, then do ' ... '
  • We need to set a command for it to do. As the line is in the middle or the robot, this means we need to go straight. We add the 'go ... at speed ...' block from the motor section next to 'then' as seen in the photo to the left.

Step 3  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 cog next to the top 'if';
  • Drag across 'else if' and place under the first 'if'.

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

  • 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 4  Moving right

Moving right is essential the same as the step above, except we need to change some variables.

  • Create a new 'else if' section;
  • Change the 'else if' by adding the 'line position ... was triggered' block;
  • Change this variable to 'right'.
  • Change 'then' add the 'go ... at speed ...' command;
  • Change these variables to 'right' at speed 'medium'

Step 5  For tighter turns