Skip to main content

Introduction

1 line sensor is great, but we can't follow a complicated path - using two sensors however lets us do much more complex things!

  1. Assemble your robot like the last section.
    • Assemble your robot like the last section.

    • Plug the left sensor in P1, and the right into P0.

  2. Let's test both sensors so we know how they work. Build the test program in the picture - can you guess what it will do?
    • Let's test both sensors so we know how they work.

    • Build the test program in the picture - can you guess what it will do?

    • Program the robot, and place the line sensor over the line on the other side of the activity mat, so it can complete the calibration sequence like before.

    • Don't forget, you need to use this calibration block every time you use the line sensor, and place the robot on the black line when you first turn it on.

    • Slowly move the line sensor side to side across one of the lines.

    • What happens to the motors? Does it do what you expected?

  3. We need to write a program using the two sensors that follows the black track.
    • We need to write a program using the two sensors that follows the black track.

    • Let's consider each of the possibilities in turn, as shown in the diagram:

    • A - Off the track completely - both sensors read 1

    • B - Slightly off to the left of the track - left sensor reads 1, right sensor reads 0

    • C - Slightly off to the right of the track - left sensor reads 0, right sensor reads 1

    • D - on the track, both sensors read 0

  4. For case A, if the robot goes off the track we need to make it stop so it doesn't drive off forever! Start your line following program by building the program in the picture.
    • For case A, if the robot goes off the track we need to make it stop so it doesn't drive off forever!

    • Start your line following program by building the program in the picture.

    • We need to check if the left sensor is 1 AND if the right sensor is 1 at the same time - we can do this with an AND block, which you can find in the Logic menu.

  5. For case B, we are slightly too far left, so we need to turn right to get back on the line. Add some more blocks to check the sensors, and turn right if we are slightly to the left of the track.
    • For case B, we are slightly too far left, so we need to turn right to get back on the line.

    • Add some more blocks to check the sensors, and turn right if we are slightly to the left of the track.

    • There are some hint blocks if you need them!

  6. For case C, we are too far right, so need to turn left to get back on the track. Add some more blocks to your program to check the sensors and turn left if we need to!
    • For case C, we are too far right, so need to turn left to get back on the track.

    • Add some more blocks to your program to check the sensors and turn left if we need to!

    • There are some more hint blocks if you need them.

  7. Finally, we need to check for case D - both sensors are 0 so we are on the track, and just need to go forwards. And some more blocks to your program to complete it, and test your robot on the track.
    • Finally, we need to check for case D - both sensors are 0 so we are on the track, and just need to go forwards.

    • And some more blocks to your program to complete it, and test your robot on the track.

    • It should be able to make it all the way around on its own!

    • If you're robot keeps coming off the track, try slowing it down.

  8. Currently, if the robot goes off the path completely (or the path ends) it just stops.
    • Currently, if the robot goes off the path completely (or the path ends) it just stops.

    • It would be more useful if the robot tried to find the path again!

    • Change your program so that instead of stopping, the robot drives so that it might find the path again. You can make this as complex as you like!

    • Some ideas:

    • Reverse in a straight line

    • Drive forwards whilst sweeping left and right

    • Drive in increasing size squares (hard)

    • Drive in an increasing size spiral (v. hard!)

Finish Line

Tech Camp

Member since: 10/03/2012

119 Guides authored

Team

Tech Camp Staff Member of Tech Camp Staff

6 Members

140 Guides authored