Apr 10

Pushing Pixels


I’ve gotten quite a few questions regarding how to hook up and drive the Sure Electronics LED matrices I use in some of my projects, so here’s a quick brain dump on what you need to do.

First off you’ll need to purchase some of the LED matrices. Sure Electronics has a storefront on eBay. There are 2 models of LED panel I’ve used: a 24×16 panel and a 32×8 panel. Prices are usually around $10-$12 each and depending on the day you check are available in various colors.

There are a variety of libraries that will drive these displays, so generally speaking you won’t need to know all the details on the interface protocol. But it’s useful to have the reference material available should you need it.

The Sure Electronics datasheet covers the cable pin connections and a high level overview of how to drive the display: http://www.sure-electronics.net/download/DE-DP017_Ver1.0_EN.pdf

Both of these displays use a Holtek HT1632 LED driver. The HT1632 datasheet goes into a bit more detail on how the chip works and the various modes, initialization procedure, etc.

Wiring Them Up

The displays come with a pair of ribbon cables which allows you to daisy-chain the displays together. So you only need the first display wired up to your microcontroller and the rest of them will chain off the first. Since they are all wired up to the same signals you need a way to identify the displays to address them from your code. This is handled with jumper switches on the front.

jumperThe jumpers are labeled CS1 through CS4. Each display should have one and only one of these switches flipped to the On position to set its ID. If two displays have the same ID, they will act as clones of each other and the same image will appear on both.


The way I wire them up to my Arduino boards is as follows:

Signal LED Matrix Pin Arduino Pin Notes
+5V 16 5V Data sheet indicates this can pull 350mA of current max so make sure your regulator is up to the task.
GND 15 GND  
WR 5 Any Digital I/O Write clock
Data 7 Any Digital I/O Data to write
CS1..4 1..4 Any Digital I/O You’ll need to connect a CS pin to a discrete digital I/O pin for each display you are driving

Software & Support

You’re spoiled for choice here – there are numerous libraries floating around.

There’s an epic thread on the Arduino forums covering how to interface to these displays. Among the 17 pages of posts are a variety of demos and sample libraries to use.

Adam Lloyd has a library that he maintains at http://github.com/devdsp/HT1632-AVR that supports reading from the display’s backbuffer as well as writing to it. If you do this you’ll need to wire up pin 6 on the matrix as well.

My library is available as well: SureLEDMatrix.zip and here’s a quick example on how to use it:

#include <SureLEDMatrix.h>

// —- PIN Constants ———————————-
int PIN_CHIPSELECT_1 = 5;  // CS for LED matrix 1
int PIN_CHIPSELECT_2 = 6;  // CS for LED matrix 2
int PIN_WRITE = 7;
int PIN_DATA = 8;

// Instance of LED matrices
SureLEDMatrix matrix1(PIN_CHIPSELECT_1, PIN_WRITE, PIN_DATA, kMatrixType_24x16);
SureLEDMatrix matrix2(PIN_CHIPSELECT_2, PIN_WRITE, PIN_DATA, kMatrixType_24x16);

int scroll = 0;
int maxscroll = 200;

void setup()
  // Initialize I/O pins
  pinMode(PIN_DATA, OUTPUT);

  // Initialize the LED matrices

void loop()
    // Draw the text on the right screen
    matrix1.DrawText("Hello Cleveland!", 7, scroll, false);
    // Draw the text on the left screen (24 pixels to the left)
    matrix2.DrawText("Hello Cleveland!", 7, scroll-24, false);
    // Scroll 1 pixel to the left
    scroll = scroll-1;
    if (scroll < -maxscroll)
      scroll = 100;

Sep 09

Facebook “Wall”

led matrix This is still a work in progress, but I took a couple of the LED matrix panels mentioned in a previous entry and combined them with a small OLED display. They’re driven by software on a PC that pulls updates from Twitter and Facebook and shows them on the display.

Eventually I’ll build a few of these into some nice enclosures and hang them on the wall to make a literal Facebook wall.


Sep 09

1,000 Points of Light


When I finally get around to writing my self-help book, it will be entitled Everything I Needed To Know About Life, I Learned From The Apple ][. It was my first computer and to really get the most out of it you needed to understand how it worked at the lowest levels. It was the period of my life when I had no money and nearly infinite time, so spending weeks reverse-engineering games and copy protection schemes to understand how they worked was the norm. I learned persistence, dealing with constraints and a work ethic from those experiences. Like any formative experience, it left an indelible impression on me. If I’m ever called-upon to testify in a court of law, I’d like to be sworn in with one hand on The Red Book.

One of the valuable lessons I learned was that hardware designers behave according to a rigorous set of strictures passed down from the Marquis de Sade as a way of torturing software developers. I know just enough about hardware to recognize the brilliance of Steve Wozniak’s Apple ][ design. But the savings of a few logic gates led to one of the most bizarre frame buffers I’ve ever encountered – the Apple ][ hi-res bitmap display.

First off, it’s a 1-bit per pixel display that can display 6 colors (or even 7 colors because there’s a half-pixel shifted version of white – I’m not making this up!). I’m not going to explain how that works, but only mention it because when I was 12 I thought it was completely normal and that’s just how computer graphics worked. It was the raster graphics version of being raised by wolves. Each byte contains 7 pixels of data in the lower 7 bits, but they are in reverse order. So the leftmost pixel is the least-significant bit. Thus, as you march across the screen you end up going right in bytes, but left in bits which then translates into right in pixels. I think this is where Michael Jackson got the inspiration for the Moonwalk. And that 8th bit is special and relates to the colors, so converting a bitmap to Apple ][ native format requires insane feats of bit-shifting, bit reversing and dividing by 7. It’s bizarre and completely nonsensical, and 30 years later I can still do it in my head without even thinking. Woz, if you’re reading this, I want those neurons back.

The cherry on top is that once you’ve zig-zagged your way across an entire scanline your reward is that you need to do some tests and math to calculate the address of the next scanline because (ahem) the scanlines are interleaved.

Now Let’s Complicate Things

I encountered something that is actually a little bit more bizarre recently. There’s a company called Sure Electronics that sells very inexpensive LED matrix panels. They sell a nice 24×16 panel for $10 that includes a driver you can control with a simple serial protocol. That’s a hell of a deal and was just what I needed for some wall displays I was building. Interestingly they use a Moonwalk-style memory layout as well, but theirs jumps every 4 bits instead of 7 and it’s rotated 90 degrees. Yes, the pixels are laid out in column-order rather than row order.

But at a price of under $0.03 per LED I’ll happily fix it in software. They have 2 panel sizes: a 32×8 panel that is good for displaying a single line of text and then a 24×16 panel that isn’t really good for anything but is cool.

32x8 LED Panel32×8 LED Panel available in red, green or yellow



24×16 LED Panel

I stuck 2 of the 32×8 panels and one of the 24×16 panels in a custom laser-cut acrylic enclosure to use as a status display for work. It’s driven by a Modern Device RBBB Arduino microcontroller board and connects up to a PC through a FTDI USB-to-Serial cable. This allows the board to be bus-powered and have a convenient serial-connection to the PC which allows live update of data to the display.

IMG_0019 IMG_0020

The Right Abstractions

Having a live connection to the PC also meant I could deal with the insanity of the frame buffer on the PC and just feed ready-made bitmaps to the display panel over the serial link. This keeps the complexity on the PC where we have rich debugging tools and the microcontroller code is dirt simple. It just reads bitmaps from the serial link and blasts them directly to the LED panel.

Here’s a video of a test pattern animation running on the display:

LED Wall Display

The display title at the top was cut from white acrylic on a laser cutter. Here’s a brief video of the laser cutter doing it’s thing. If you look closely you can see small flames jumping up off the acrylic as it’s being cut.


This project was a test of the LED panels and how fast I could drive them in preparation for a more ambitious project to build a wall display to show Facebook updates. For that one I’ll want to add a separate color display to show profile pictures.