Raspberry_Pi_Education_Manual

Notes:

Line-following vehicle (LFV)

Resources: The sprite “ yellow_car ” and the background “ line_background ”.

That robot is like something out of a corny science-fiction film. Let’s look at a more modern example. Scientists are experimenting with vehicles that can drive themselves. One way of doing this is by programming the vehicle to follow a line painted on the road surface. These vehicles are known as “line-following vehicles”, or LFVs.

In this exercise, we’ll look in more detail at the blocks in the Sensing section.

The Sensing script blocks allow your program to sense

changes in its environment, either in

response to user input or events in the program.

Our task is to make a car to follow a line, just like the real engineers designing LFVs for use on the roads. Our main tool is going to be the “color [ ] is touching [ ]?” block from the Sensing menu.

This block allows a program to detect when an area of one colour touches against another colour: for instance, as in the screenshot above, a patch of red touches a patch of black.

A beginner’s guide to Scratch

38

Made with FlippingBook flipbook maker