Starting the Motors
1. Start with a pause block to give you time to put the BitBot on the floor. Then use the “Drive motors” block from the “BitBot > Motors” block menu. Choose “both” motors and set the speed to 600.
2. Download the code and copy it to your microbit. Turn the BitBot on, and then put it on the floor. Does it move? Does it stop moving??
3. To stop the motors, you need to pause your code until you have moved as far as you want, then set the speed to zero.
Can you make the BitBot move backwards?
Turning
1. You can turn corners by setting the speed of just one motor. This code turns the left motor for 5 seconds:
Can you make the BitBot turn on the spot by driving one motor forward and one motor backwards?
Using Functions
If you wanted the BitBot to move in a complicated pattern it would take a lot of code! You can make this simpler by creating “functions” which combine common sets of commands.
1. To make a function, click the “Functions” menu in the Advanced Block Menu
2. Then click “Make a function. You will be asked to enter a name for your function, and then you will see an empty function definition block
3. You can put any code inside a function. Add the code to move forwards for 5 seconds
4. The code in your function won’t run until you call it. If you click the “Functions” menu again, you will see a new block called “Call Function”. Change your onStart command to call your function
5. Download your code and check it works!
Can you make two more functions which turn left and right? Experiment with your new functions to make your BitBot move around!