Week 7 – 2019 – Sara

Hi there….

If your wondering why I didn’t write my blog last week well it’s because there was no robotics (James was sick). But I’m back at it again this week, and here’s what I did.

I worked on my 2 Sensor Line Follower again, the one from week 6 worked only on straight lines and some curves but this week I managed to get it going on staright lines and all curves. First Rich showed me a truth table, here’s an example of one…

This pretty much explains what should happen on all four of these situations. The first three are self explanatory but the last one is a bit different, the last one says not black on both sensors which means it’s either on green or silver. Green and silver also reflect less than 40 which is like black.

Line Follower 2.0
You can click on the picture to make it bigger

That was today’s finished code, I put in some notes to make it easier to understand. Here’s the big (and long) explanation…

I created 3 variable blocks, Speed, Turn Angle and Reflected Light. This is so that when I have to change one of these things I only change it on the variable block and it automatically changes the rest. After all these variable blocks theres a switch block, using the left sensor it will look for how much reflected light there is if its greater than 40 then it should continue by going upwards, if its less than 40 then it should go down ( I’ll explain the up part first). After this theres another switch block telling it the same thing (if its greater than 40 go up, if not go down.) The only difference is that this time its using the right sensor to do this. (Going up once again) This part says that since both sensor are greater than 40 indicating its on white, it should go forward with a speed of 37.5 ( I’ll explain why that is soon). Now if the left sensor is greater than 40 and the right sensor is not then the robot should turn right 187.5 degrees with a speed of 37.5. By turning it will make the robot get back with both sensors on white again and when that happens it will move forward.

We’re finally at the bottom part of the code! The bottom part is when the left sensor is less than 40, it then has another switch block. Using the right sensor it asks if its less than 40, if yes go up if not go down. (Going up this time, it’s the last time.) Now it gets a bit complicated, it takes the Turning Angle times it by -1 and then puts the answer as the new Turning Angle. Which now means that when the left sensor is less than 40 (meaning its black) and the right sensor is greater than 40 (meaning white) the robot will turn left -187.5 degrees. The last and final line of my code is when neither one of the sensors are greater than 40, (which means they are both a dark colour) when they are under 40 the robot must stop.

For me to get the right Speed and Turning Angle I changed the speed right down to 15 and experimented with which Turning Angle worked best on the sharp curves. In the end I had Speed at 15 and Turning Angle at 75, but I found that the robot was really slow so I multiplied both these numbers by 2.5 and got the answer that I used on my code, a Speed of 37.5 and a Turning Angle of 187.5.

Finally done with it all, ok bye…