11 Mission Instructions
Your mission is to create a cookie delivery robot.
5. Code: How does the Line Follower Work?
Before we attempt any code with the line follower, let’s have a look at how this sensor works.
Underneath the sensor, closest to the floor, you have five individual light sensors. They’re not quite the same as the light sensor we used before but they are similar. They will react differently if they are just above a dark surface or just above a light surface. Each one of them will detect whether it’s over white or black.
In Bloxter we can write a VERY simple program to tell our robot to follow a line. All we need is two blocks - one to tell the GoPiGo to "follow the line until" and another to tell it when to stop. In the example below the GoPiGo will stop following the line when the line sensor reads all white (there isn't a line any longer). The example program also includes one more block - "set speed to slow".
This helps to improve accuracy when following the line.
BUT, that is way too easy. You can use a simple program like the one shown below to test out your robot to see how it follows a line, however let's make a program that tells the GoPiGo what to do when the line follower senses that it is too far to the right or too far to the left.