Sunday, 7 October 2012

sending dynamic text from the Pi to the LoL Shield via Gertboard

Getting fixed scrolling text on the LoL Shield from the uploaded arduino program is one thing (see previous posting), but we really want to get the text delivered into the program dynamically. This is where the serial GPIOs on the Pi can help out.

I wrote a small arduino program to read characters from the serial port and display them on the LoL Shield. Note that I had to edit the Charlieplex.cpp file from the LoLShield library to remove a (apparently unused) Serial.end() call. Line 373 on my copy.

Once the program is uploaded to your ATmega on the Gertboard, you can deliver text via serial on the Pi using any method you like, e.g. interactively via one of:

  • minicom ama0
  • screen /dev/ttyAMA0 9600
(Press return to tell the program you've finished entering your characters.)

Alternatively, you can send your text programmatically via a python, C, bash script by writing to the /dev/ttyAMA0 device, e.g.:

  • $ echo 'weeee!' > /dev/ttyAMA0 
Remember, when sending/receiving serial data between the Pi and the Gertboard's ATmega, you must connect the GP14-15 pins in J2 to the MCTX and MCRX pins just above them.

// displays text sent via serial e.g.
// echo 'weeee!' > /dev/ttyAMA0
#include "Charliplexing.h"
#include "Myfont.h"
#include "Arduino.h"

unsigned char buffer[140];
int c;
int i = 0;
int len;

void setup() {

void doMsg() {
    Myfont::Banner(len, buffer);

void loop() {
    if(Serial.available()) {
        int c =;
        if(c != -1) {
            if(c == '\n' || c == '\r') {
                buffer[i] = '\0';
                len = i;
                i = 0;
            } else {
                buffer[i++] = c;
    } else {
        if(len > 0) {

Wednesday, 3 October 2012

LoL Shield on Gertboard

Bought a giant LoL (lots of LEDs) shield from Olimex on Ebay. This shield has a matrix of 9x14 LEDs which can be individually driven. The shield has pinouts for Arduino boards, but wiring up 12 digital outputs from the ATmega chip on the Gertboard (PD0-PB5) to 12 digital inputs on the shield (2-13) allows the arduino IDE on the pi to drive the shield perfectly. Take a look at arduino images on the web to see where the digital pins 2-13 would connect to your shield.

Download the library from  and place it in ~/sketchbook/libraries (create these directories if they don't exist),  then restart arduino IDE if open, and finally open the LolShield/examples directory in your arduino IDE and upload.

Note that I had to placate the compiler with a couple of 'const' references in the LolShield example/library code, and I had to remove the programming wires from the Gertboard after uploading to prevent the pi's GPIO pins from interfering with the ATmega chip at runtime.

The LoL Shield library lets you do loads of cool things from scrolling text, to vu-meters. I'll be having fun for some time, I think!