Create a micro:bit Robot with Grove Zero
This guides goes into basic details on how to use the Grove Zero motor add-on.
In this guide, you will learn how to transform your micro:bit into a robot with the motor add-on. This micro:bit robot will be fully programable by you!
After completing this guide, you will understand how to program a robot using MakeCode and have a fully functional robot.
Step 1 First lines of code
- When opening a new project, or your first project, you will be greeted with two blocks 'on start' and 'forever'.
- Anything in the 'on start' block will only run once when the micro bit starts up; this is useful for commands which are needed to set up the environment.
- Anything in the 'forever' block will run in a continues loop through the order which it is placed. This is were the bulk of your code will go.
- To begin, place the 'go ... at speed ...' block from the motor section into the 'on start' block. You can set the direction and speed from the two pull down menus.
Step 2 The pause function
- Add the block 'pause (ms) ...' (found in the basic category) underneath the 'go ... at speed ...' block. Set the pause to 1000 ms.
- This command halts the progression through your list of commands for an amount of time in ms (milliseconds). So 1000 ms will be a 1 second pause thus the micro:bit will stop progressing through the code for 1 second.
Step 3 The stop function
- As the only two lines we have so far tell the micro:bit to move in a certain direction and to pause reading the following code for 1 second. If we leave it at this the micro:bit will just keep on moving. So we need to add the 'stop' command.
- The 'stop' block is found within the motor category, place this block under the 'pause' block within the 'on start' loop.
- The stop block tells the motor to stop moving.
- What the micro:bit will do is move in the direction you see for 1 second , then stop.
Step 4 Programming the micro:bit
- Download the hex file and copy across to the micro:bit.
- Note that to copy the files across, the micro:bit must be plugged in, not the micro:car board. The USB port of the micro:car is only used to charge the battery. NOT for programming.
Step 5 Building the grove zero
- Begin by getting the motor base (the one with the tracks) and connecting the battery/micro:bit mount on-top.
- Note that this piece is depended on the orientation. The white part of the board must face the front of the robot (the direction of the arrows on the side are pointing). Without the correct orientation, the robot will not do anything.
- The battery is located underneath the board and is surrounded by black plastic.
- Next place the micro:bit into the slot
- Lastly, turn on the power switch on the left hand side of the mounting board