Drawing With The :MOVE mini For The microbit

The :MOVE mini has a hole in the boot lid designed to accept a marker pen, such as a Sharpie, for line drawing. All it takes is a sharpie and some code...

This guide will show you how to get started with both the PXT editor for the BBC microbit using both blocks and also Java Script.

Make The :MOVE mini Draw A Circle (PXT Blocks) :

To draw a circle the outside wheel must move faster than the inside one. On a :MOVE mini we have independently controllable wheel speeds.

When the wheels are going in opposite directions the :MOVE mini will turn on the spot, and then as the wheels become close to the same speed it will make a larger, and larger circle, until it ends up going in a straight line. This code draws a small sized circle by running on motor at full speed, and one motor at 1/3 speed.

You can edit the radius of the circle by altering the write speed. Use a write speed from 90 – 0 for one servo and 90 – 180 for the other, where 0 and 180 is a straight line (allowing for variance in servos it will probably drift to one side or another).

Make The :MOVE mini Draw A Shape (Javascript):

A square has 4 equal sides, and 4 90 degree corners. We will write a program for this in JavaScript.

Because there are 4 corners and 4 edges it is worth writing control functions for turning and driving to do this, rather than writing the same code 4 times.

In the PXT java editor create the following variables. We will use these to store some constants about our :MOVE mini.

Next we will make a function that takes the desired number of degrees to turn and drives the servos to achieve that.

Because we do not have position feedback from the 360 degree servos we have to use time and a knowledge of how fast the :MOVE mini is to make the turn.

To do this we will turn on the servos, wait a period, and then turn them off. The following function turns left through approximately the requested number of degrees.

Program button A to call this function like this (note: there is a pause to allow you to move your hand before the :MOVE mini starts turning).

You can fine tune the number of degrees per second constant so that the :MOVE mini turns through 90 degrees.

Next make a function to cause the :MOVE mini to drive forwards:

Program button B to call this function like this:

Fine tune how far the :MOVE mini drives by changing the distance per second constant. You might want to make it 10cm for a 10 for instance.

Now we have the building blocks to make the :MOVE mini draw a shape.

To draw a square when button A is pressed change the code in the onButtonPressed function to:

This will draw a basic 4 sided shape, which if your turns are accurate will be a square.

For further tasks see if you can write code to make the :MOVE mini turn right, and drive backwards.

Combine that code to draw other shapes / pictures.

Kitronik Custom Blocks For The microbit Javascript Block Editor:

We’ve also created some custom blocks for the microbit Javascript Block editor. These can be found in the Kitronik github repository. For the Servo:Light board, the address is:

In the JavaScript Block editor click the ‘Advanced’ button in the toolbox, then click the ‘Add Package’ button and type in the github URL. Press the search magnifying glass and the package should appear:

Simply click on it to add it to the project. You will now have access to the following blocks:

Downloads:

For those that want to get drawing straight away we've included the zip file below that contains all of the code above as three separate hex files.

Note: Unzip the file and either drag the HEX file into the PXT editor for editing or connect your microbit to your computer and drop the file directly onto your microbit via your file explorer. The microbit should show up as a removable drive.