Get your ChickBot micro:bit moving

Let’s get those wheels turning!

The micro:bit has three pins numbered 0, 1 & 2 that you can see on the copper edge. But it also has three other pins, P8, P12 & P16, that we can connect to when the micro:bit is plugged into the ChickBot driver board.

P0 is connected to the piezo but can be used as an input or output, analog or digital, if you remove the jumper next to the piezo. P1 is available in the same way but doesn’t need any jumper removing. The A & B buttons can be connected up to switches if you want but they can only do digital – on or off. Pin P2 along with the ‘hidden’ three pins, P8, P12 & P16 are connected to the chip on the driver board that allows us to control two motors. We can program them individually and we can choose if they should go forward or backward or be stopped. By sending one motor forward whilst the other one is stopped, the ChickBot will turn. If you have one motor going forward and the other going backward, the ChickBot will turn on the spot.

Warning: it’s almost impossible to know which way round the motor leads need to go – so don’t be surprised if your wheels go in different directions at first. It’s simple enough to rewire them so that they go the right way round at your command.

Create this Block Editor program:

Click to enlarge

Click to enlarge

You’ll find the digital write block in the Pins section and the pause is in the Basic section. Compile & download to your micro:bit, plug it into the ChickBot if it’s not already, put the power jumper on and press the A button. The ChickBot will move for 1 second.

As we warned above, it may be that the motors don’t turn in the way we expect. We think of the wheel end of the ChickBot as the front – if you’re lucky, it will have moved forward.

If not, don’t worry, it’s simple enough to get them going the right way. If you look at the axle of a wheel, the right hand motor needs to turn clockwise and the left hand motor needs to turn anti-clockwise. If you need to change the direction of a motor, make a note of which way round the wires are screwed in, unscrew them, swap them over and tighten up the screws.

The first two digital writes turn on the motors, P8 turns on the right hand motor, P2 turns on the left hand motor. By sending a 1 to the pin, it turns it on, so you’ll quickly figure that sending a 0 turns off the motor. For this very simple program, we only have control of the motors going forward. You can change the pause to be longer or shorter. By duplicating or adding  blocks you can have it stop for a time then move off again. To turn, just turn on one motor for an amount of time. You’ll need to figure out how long the pause needs to be to move forward or turn a certain amount. You’ll also have to figure out which motor makes the ChickBot turn in a particular direction.