Friday 15 January 2016

CodeBug


The CodeBug suffered from terrible timing when it launched on Kickstarter earlier this year. While the project had been in stealth mode for a significant period, it went live just after the BBC announced its own micro:bit microcontroller project – leading people to assume the CodeBug was ripping off the micro:bit, rather than the micro:bit having been inspired by the CodeBug. That didn’t prevent it from being successfully funded, though, and with the micro:bit now delayed into early 2016, the CodeBug is enjoying reasonable success in the education sector.


It’s easy to dismiss the CodeBug as a toy thanks to its cutesy design – a design ditched by the BBC in favour of a more utilitarian micro:bit – but it’s practical as well as cutesy. The two buttons sit clear of the main body for easy access without fouling the micro-USB connector, and the oversized power and GPIO connections are well suited to crocodile clips or conductive thread projects. Wearable use has definitely been at the forefront: as well as the thread-ready eyelets, there’s a battery holder on the back for a CR2032 cell.

At its heart, the CodeBug runs a Microchip PIC18F microcontroller, which might not be as familiar as an Atmel ATmega or an ARM-based microprocessor, but the real secret sauce behind the CodeBug’s popularity lies not in the hardware itself but in the software, which runs completely in the user’s browser.

The main programming interface is based heavily on the Scratch-style visual programming paradigm, with simple blocks representing everything from loops and logic comparators to controls for the on-board 5x5 LED matrix. The blocks are dragged onto a central sheet and then organised according to the way you want your program to flow.

Some people are sceptical about blockbased visual programming systems, but they offer a great way for beginners to get started and help teach the central concepts – after all, is it really that different from the dark old days when learning to program involved drawing interminable flow-charts on paper?

A code viewer also lets you see what’s happening under the hood, although there’s no support for editing within the IDE. However, a really neat feature of CodeBug’s online IDE is located at the top of the page: a simulator that allows you to see exactly what your program will do, even if you don’t have a physical CodeBug to hand. We’d love to see more of these types of features from microcontroller developers.

Compiling and flashing your code has been made as simple as possible, too. Hit the Download button, and you’ll be given a compiled version of your program. Connect the CodeBug’s micro-USB cable while holding the left-hand button and it appears as a USB Mass Storage Device; drag and drop the file to this device, eject it and you’re done. If you’ve ever wrestled with errors from avrdude about device signatures and timing, it’s a breath of fresh air – albeit one borrowed from the ARM mbed family.

While the CodeBug concentrates largely on simple educational programming tasks – typically involving animations on the LED matrix – it does have one last trick up its sleeve: an expansion header on the bottom, which can be connected directly to any device that supports the I²C protocol.

It’s designed primarily for the Raspberry Pi, although devices without direct I²C support can also be connected via the USB port in ‘tethered mode’.

Will the CodeBug replace the Arduino in many hobbyist projects? Unlikely. Is it a good introduction to coding for beginners? I’d say so, and at a price of just £15 inc VAT from http://cpc.farnell.com (code SC13932), it doesn’t break the bank either.