Bitbot Starter Guide Part 5
Bitbot Starter Guide Part 5
Page 1 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
❏ Now we need to continuously send the tilt data over radio. We can separate the tilt
data into pitch (forward/backwards) and roll (side to side). In order to do this, we’ll
use the radio send value block with name and value pairs, so that we can
recognise the values when they are received by the Bitbot.
Hint: t o type “pitch” and “roll” do a search for “text” and you’ll find a bubble that will
let you add text instead of a number.
❏ Write this code to your controller micro:bit and put it aside. Now we are ready to
program the micro:bit that sits in the Bit:bot robot.
Page 2 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
Page 3 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
You’ll need to create two more variables: rightMotor, and leftMotor for the above
code.
❏ These variables are used to hold the speed we want each motor to run at. But
before we send these to the motors, we should check if the micro:bit controller is
not tilted left or right. Although this should be 0 degrees, we’re human so we’ll say
between -10 and 10 degree just to make the controls a bit easier.
If the controller is not tilted left or right, then we’ll use the pitch (forward/backward)
to get the speed and direction to more in a straight line.
To check whether the roll value is between -10 or 10, we need another if..then block
with the condition shown below (put it in the forever loop, just below the other two
if blocks):
Page 4 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
❏ To move forwards in a straight line, we just set both motorRight and motorLeft
values to the rawPitch value. Remember, the rawPitch value is the angle that the
controller micro:bit is tilted forwards or back (we multiply by -1 because it makes
more sense that tilting the micro:bit controller forward makes the Bitbot go forwards.
Page 5 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
Although these values are what we found to work for us, you may want to play with
the numbers to get a more or less responsive robot. You can also add additional
commands to your controller, such as pressing the A and B buttons to operate the
LEDs.
We’ll leave these to you as an additional challenge!
Page 6 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
The complete code for the receiving Bitbot micro:bit is as follows:
Page 7 of 8
4tronix makecode starter guide: Part 5 - Bitbot Radio
Page 8 of 8