Week 3 – 2019 – Sara

Hello there!

This week in coding we did quite a lot. Here’s a few things we did…

First we started off by changing our code from last week (the one that made the robot make a square). Instead of making one wheel stop and wait for the other to spin 409 degrees, we made both the wheels keep moving, each in a different direction, thus making the robot move back and turn 90 degrees at the same time.

After this we started using the colour sensor. We had to use pseudocode once again to write our code later on, here was my pseudocode for the robot to detect the colour green…

Step 1: Move forward

Step 2: If green found completely stop

Step 3: If nothing found repeat until green is detected

That was my code for the robot to detect the colour green. It worked quite well, when I put the green Lego piece in front of it, it detected it and stopped, it stayed there until I removed the Lego block then it moved forward again searching for some more green.

This was my next challenge…

Step 1: Move forward

Step 2: If green found completely stop, if not keep moving forward.

Step 3: If red found stop and wiggle 5 times, if not keep moving forward.

Step 4: If no colour is detected keep moving until something is found…

That was my finished code. The first block told the robot to move forward at a speed of 50, the second block told it to look for the colour green, then it had a switch block after that which meant that if green was found the robot should stop but if it wasn’t found then it should keep moving. After that it had another switch block, but this time it was looking for the colour red, if red was found then it should stop and wiggle on the spot 5 times, if not then it would keep moving until one of the 2 colours were found. All of this was put inside a loop block, which meant it was going to keep doing this until someone stopped the robot.

Ok I guess that’s it, I’ll write again soon with more to tell from our next time at robotics…