Get Help
Line Following (miniBloq)
Introduction
Sparki can use the sensors below the hands to sense edges and lines. In this tutorial you’ll have Sparki follow a line.What You’ll Need
- A Sparki.
- A path line for it to follow, like the poster in ArcBotics’ Sparki Materials Packs:
How It Works
Sparki has an array of infrared sensors underneath that it uses to detect if there are lines below it. We’re going to program Sparki to follow the dark lines in our path, since they are printed over a more reflective background (typically, the path is printed in dark black, over a white background).
Infrared reflectance sensors can be thought of as an infrared light (which humans can not see), and some special eyes that look at that light. The eyes are made out of a special photo sensible material and an infrared emitter, typically a LED (or Light Emitting Diode):
Here are the parts again, but with pictures showing what you’d normally think of them as!
Converting the Sparki in a line following robot
Following a Line
So, let’s use these sensors to make the Sparki to follow printed lines in the floor.
Here is the complete miniBloq code that makes Sparki move according to its sensor states, as shown in the previous image:
Congrats! You have programmed Sparki to follow a line!
Just a note about the blocks used to rotate and move the robot forward: as you can see in the code above, they receive a 0 (zero) number as the parameter. This means that they will rotate or move indefinitely until they receive a new moving command. So, if we have Sparki rotate left with its degrees parameter set at 0, it will continue rotating in that direction until a move forward, backward or rotate right block is executed in the program.
Extra Activities
- Of course, there are other techniques to follow lines with a robot, such as with two sensors instead of three, or even with one! Why not take a look out there in the Internet to see if you can find new ways of doing this?
- If the line forks, which way will Sparki turn? Is there a way you can give it directions with the remote as it comes to a split in the road? Are there ways you could have Sparki tell you when it has reached a branching path?
- What about following a line that is wider than the distance between the left and the right sensor?
SparkiDuino Programming Environment
This lesson is also available for the SparkiDuino Programming Environment. SparkiDuino will allow you to program your Sparki using standard Arduino syntax.