Week 11 (1) – Oliver – 2019

Today I only had to make one last change to my line-following code to get it working. The code could run the robot around hints, through the sharp turns and over the ramp.

But there was only one challenge that had not been tackled – stopping at the silver indicating the start of the chemical spill and finding the can. I achieved one of those problems today in the code below:

This slightly blurry program is what I have been working on for the last year.

Today I added the major switch block in the fourth instance. I found out how to make a triple switch block to split the code into 3 parts. The part of the project I was working on was hints, the ramp and stopping on silver. To achieve this, I inserted a text variable called TurnDirection with 3 possible outcomes: F, L and R. The variable is changed every time the program runs through any of the top parts of the program: Left, Right and Forward turns. All I did was insert a variable write block to set the variables.

When the robot drops down into the fourth part of the code, it turns on a red status light indicating that the code is currently running in the hint part. It then reads the variable and directs the program into one of the three branches. Each branch then contains another switch block that deduces if the difference between the colour sensor outputs is equal to or less than 5. If so, then the robot assumes it is on grey. However, I noticed the robot also stopped at the beginning of the ramp.

To fix this issue, I made a variable to track whether the robot has gone over the ramp or not. The first time the code runs through the less than or equal to 5 part, it assumes it is on the ramp and goes forwards at a speed of 50 for 2.3 full wheel rotations. It then switches the ramp found variable to true, so the next time it finds the sensors having a difference of less than or equal to 5 it would cut out of the main loop and start searching for the can.

On Thursday this week, I have to bring in my can finder program on a USB stick from my laptop at home and improve on the old files. I also have to run a few tests to make sure the code runs consistently.

Useless fact of the Day: 14% of all facts and statistics are made up and 27% of people know that fact. Okayyyy..?