Week 11 – Josh

Today at Mindstorms we looked at a 2 light sensor line follower.  We got started by watching a video of somebody else’s and realised it worked a lot smoother.

I then wrote some pseudocode.

  1. If both sensors see white go fast forward.
  2. If left sensor sees white and right sees black then turn left.
  3. If left senor sees black and right sees white then turn right.
  4. If both sees black then stop program.

I got the basic idea of how to do it fairly quickly.  But then I struck a problem when I put it on the line it turned the wrong way.  I had a bug, the motors were the wrong way round.  We worked on a double sensor follower because in the competition there are green squares (Hints) to tell you which way you go at the junction.  Bellow is the table of the situations that could happen with the sensors.

What code tells motors to do in table format

We also struck another problem that the turn and speed needed to be tuned correctly so it would make the turns.

We used variables for speed and turn rate so that we didn’t have to do it individually and make mistakes.

Here is our final code.

As you can see the last switch block has a stop sign so next week we will work on the next bit using that to read the hints.

Our Mindstorm Adventures continue.