The BBC micro:bit is a compact microcontroller board populated with sensors and wireless connectivity. It also has several programming languages (graphical and text based) and is super-easy to use. No software or account is needed; just traverse to the BBC micro:bit website and begin coding. I tried out the website for a while at the weekend to check it out, and this blog post provides a quick summary of an initial experiment.
Note: jlucas is running a series of micro:bit projects currently, I had not realized. This post isn't to detract from that, this project is more "experimental" status (i.e. it has not been tested for real!) and requires some circuitry too.
The programs can be immediately simulated (for most of the programming languages on offer) and when you're ready you can download the program and drag-and-drop it using Windows Explorer onto the USB-connected micro:bit which will look like a USB memory stick to the PC.
Although micro:bits are not available just yet (they are pre-orderable now), I thought it would be interesting to do some simulation experiments. In theory it should work on the real hardware too.
Here is an attempt at turning the micro:bit into a turtle, to draw shapes such as triangles or stars.
What does it do?
It draws shapes. To do this, a motor (and driver circuit) and wheels are connected to the micro:bit. There is an on-board electronic compass which is used to determine which direction the micro:bit is pointing. When button A is pressed it will power the motor for a fixed period of time and draw a straight like as the micro:bit moves. Then it will sit and wait until the user manually rotates the assembly by a certain number of degrees. As soon as this occurs the motor will be powered on again and the second line will be drawn. This process is repeated until the shape is complete.
During the process the micro:bit 5x5 array LED display is used to provide some basic prompting to the user.
What is needed?
Nothing is needed to test it out. Just a browser! The attached file (unzip it first, the required file has a .jsz suffix) can be imported or dragged into the BBC micro:bit website view in order to try it out. There is a rotational control in the browser that simulates the orientation of the micro:bit.
If you wish to type it yourself, the code is shown in the screenshot further below.
It could be downloaded to a real micro:bit or simulated and an arrow will be drawn on the LED array to simulate the motor motion.
To try it out for real, a motor driver circuit needs to be connected to P0 on the micro:bit. A very low power motor could be attached using a single transistor circuit.
It was fun and very easy to write this program using Microsoft's TouchDevelop programming language. Although final accuracy of the shape will depend on the quality of the wheels, grip and mechanical construction (and sometimes, it is more fun experimenting to try to improve things anyway) it can be seen that having easy-to-use built-in sensors, display and wireless connectivity (which wasn't explored in this post) will make the micro:bit very useful for projects.
Script: If it renders poorly, click to enlarge.
wondrous-polygon-script.zip 3.3 KB