Apr 5, 2016 0 comments

The MPLAB Xpress board came with an “USB drive” approach which simplifies programming, and it’s also a big money-saver as we don’t need even a PICKIT3. But the idea behind this is not entirely new: there’s another little device that uses the same programming approach: the CodeBug. But what can this little device do, and how it will compare against some “serious” development boards? We shall see…

The CodeBug comes in a colorful cardboard box, a hint to it’s targeted audience: for ages 8+ under adult supervision. “Learn to code the fun way!”, “It’s easy”. Encouraging.

Besides the CodeBug itself, in the box we find a colorful quick start guide, some safety instructions, and a USB cable. All we need is to add the computer.

A quick look at the CodeBug reveals a PIC18F25K50 microcontroller as its “brain”, two buttons and a set of 25 LEDs connected in a matrix, with rows being pins RA4 to RA0, and columns being pins RA5-RA7, RC0 and RC1. On the back side we will find a holder for a CR2032 battery — good if we wish to use the CodeBug as a wearable device. We will also find a set of pads to connect a PICKIT3 or similar programmer, using pogo pins.

Expansion is possible via a set of six holes, big enough to match a banana connector, or to clip a crocodile on them. Vcc, GND, and four I/O pins are provided, with 22MΩ pull-ups on each of the I/O pin. CROC1 connects to Pin RC2, CROC2 connects to Pin RB3, CROC3 goes to RB4 while CROC4 is connected to pin RB2.

To start using the CROC connectors we have the GlowBugs: little PCB’s with a NeoPixel addressable LED on each PCB, available on packs of 5 or 10 pieces. The GlowBugs can be chained using croc-clips, or we can sew them to clothes, just like the NeoPixels from Adafruit.

Another way to expand the CodeBug is via the tail connector, which breaks out the MSSP port: in I2C mode SDA and SCL lines are pins RB0 and RB1, while in SPI mode pin RB0 is SDI, RC7 is SDO (configurable via the CONFIG registers), RB1 is SCK and RC6 is CS. We will also find Vcc and GND to power the expansion boards from the CodeBug. Obviously, we can just use the pins as general I/O pins if we wish.

For the given moment there’s only one expansion available: the five-cornered ColourStar, featuring nine NeoPixels.

It’s easy. That’s what is written on the CodeBug box, and that’s exactly how the CodeBug is programmed: everything takes place online on the CodeBug website: all you have to do is to connect logical blocks, just like in Scratch. No programming experience is necessary.

After the sketch is ready we click the Download button and the download starts automatically: we will get a file with the extension .cbg. Then we connect the USB cable to the CodeBug while keeping the A button pressed. To run the code we will then press the B button. Simple as that!

I tried to look inside the .cbg file and I couldn’t recognize anything! To me it looks that the CoideBug runs some sort of interpreter, and the .cbg file contains the commands for that interpreter. Not much to do…

What about complicating things, such as programming the CodeBug in XC8/MPLAB Xpress? As the CodeBug uses a PIC18F25K50 microcontroller, and that particular microcontroller is supported in MPLAB Xpress Code Configurator that should be easy. I found out that the CodeBug does not accept .hex files. I even tried to rename the .hex files to .cbg, but nothing happened. The only way to run XC8 code is to use a PICkit3 connected on those pads on the back, but by doing so you will lose the original firmware. Bad news, as there’s no way to restore the CodeBug if the original firmware is lost.

My verdict: a fun device to play with, and an excellent way to start into microcontroller programming. Combined with I2C or SPi tethering one can do many nice things with this. Or, if you wish to make the big step and say goodbye to the CodeBug original firmware, you can just program it as any other PIC microcontroller.

Related Posts


{{posts[0].date}} {{posts[0].commentsNum}} {{messages_comments}}


{{posts[1].date}} {{posts[1].commentsNum}} {{messages_comments}}


{{posts[2].date}} {{posts[2].commentsNum}} {{messages_comments}}

Contact Form


Email *

Message *

Recent Comments