Today we will use what we learned about custom MyBlocks to make a multi-function program. Our goal is to have a robot that will complete several tasks:
- Follow the line
- Avoid the drink bottle sitting on the line
- Line follow until the robot crosses the foil
- Search for the victim (the foil covered can).
- Push the victim out of the spill.
Each function will have it’s own custom MyBlock.
By the end of the day you should end up with a main program with three blocks:
We will start today by creating a block to drive around the bottle:
You might put in an extra motor block at the end to turn back towards the line.
Now we can put our two custom blocks together to start to form our main program:
To create the first block, follow the line (and stop at the drink bottle), we will adapt our existing MyBlock, followNstopAtFoil.
Here is the block:
You can find this block in the light blue tab for ‘My Blocks’:
When you drag the block into a program and double-click on the block icon, here is what you see:
Here is a video showing you how to make the follow2bottle (or followNstopAtUltrasound) custom MyBlock:
You should end up with a main program with three blocks:
A robot running this program will follow the line to the bottle, go around the bottle, then follow the line to the foil and stop. If you want to go on to the next step, you can start coding a block to ‘Find the can’ using the same approach as we used in an earlier challenge.