My Development Process

by Jimmie on December 11, 2009

LED shield board

One of the nice things about working for myself, is that I’m able to do random things as they strike me. Yesterday morning I woke up wondering how many LEDs I could fit on an Arduino shield. This isn’t the first time I’ve wondered that, but it is the first time I decided to give it a try. I was finishing up the Open Heart V2 PCB design, so I was already in EagleCAD, and already thinking about Charlieplexing. I then downloaded the Adafruit Proto Shield design files to get the proper measurements of the header spacing. Within 5 hours or so, I was able to flush it out. I then met up with my friend Christian for some makerbotting that evening, and he suggested I blog about my design process. Read on to get both some information on my thinking process, and a solid overview of wiring up complex Charlieplexed displays.

Like most of my projects, this started with me just thinking about something random, and then the “what if” takes a hold till I flush it out. In this case I was just lying in bed when that feeling struck me. I started thinking about Charlieplexing, and how many possible LEDs you could use with an Arduino. I knew that theoretically the Arduino could use all 14 general I/O pins to drive a Charlieplexed display, which would give a total of 182 LEDs. The way to calculate that is with N*(N-1), where N is equal to the number of pins you are willing to use to drive the display. That wouldn’t be very useful though, since you could then only use the Arduino to display from memory. The communication pins must be free, so that leaves us with 12 general I/O pins, which comes to 132 LEDs.

The question for me was then whether I could fit 132 LEDs into the proto area. The answer was no, not in a way that I liked. I ended up with only 126 LEDs, which is just 6 short of the maximum. Basically I added about 20 LEDs to the schematic, and then moved them around in the shield space till I worked out how many I could fit in there comfortably. The arrangement I came up with is a 9×14 grid of 3mm LEDs, which gave the largest number in that space. It’s large enough to display text, simple video, a game, or whatever. It also leaves some room for a small proto area, which could be used for buttons/sensors connected to the analog in, or even for those last 6 LEDs.

Once I figured out how many LEDs I could fit, I got down to the ugly business of placing them. I’ve been getting a ton of practice with Eagle lately, so that didn’t prove to be as hard as it sounds. Monotonous, sure, but not difficult. This is where my OCD is actually helpful. I set all 126 LEDs into a grid patter in the schematic first, then placing them on the board. I finished both in around an hour or so. Once I finished that up, it came down to the actual business of finishing up the schematic wiring.

I decided to wire up the first eight columns in a standard configuration. That then left me the other six columns to worry about after. I’ll try to explain the process of wiring a simple Charlieplexed grid as best I can. The easiest way I’ve seen is to do a grid of N*(N-1). Each pin will ultimately have N-1 positive, and N-1 negative connections. In this example we are going to use 4 pins to drive 12 LEDs:

charliplex exampleYou will start by wiring the N-1 row or column together with either the positive or negative connections on the LEDs. I’ve chosen to wire the negative connections on the rows, and positive in the columns, but it doesn’t really matter as long as you keep them straight. Now, for the columns you are going to have to do an off-set. Remember when I said that each pin can have N-1 positive and negative connections? Well we’ve just wired up 3 negative connections to 4 pins, so now we can only place 3 positive ones on each connection. If you look closely at all of the vertical connections, I’ve only got 3 LEDs on each of the 4 pins due to the off-set.

The off-set also helps to shift all of the LEDs in a pin mapping table. Basically, you can’t connect the positive and negative of an LED to the same pin, as that will cause a short. I started wiring the top N-1 in the first column on the left to the LED connection not already wired, then I wired the top N-2, N-3, etc. Now do the same thing from the right side, but start from the bottom. You will then have a sort of diagonal line of un-connected LEDs. Now just wire the top of the second to the bottom of the first, then the top of the third to the bottom of the second, etc. The the last row on the bottom is all by itself. You should end up with N columns of N-1 LEDs. The last step is to connect rows and columns together. I like to just go with the closest, as that makes a slightly more readable schematic.

This small 3×4 gives a pin mapping like this. You’ll notice a pattern hopefully. All of the negative pins group together in blocks of 3. Then the positive ones go down till you hit the same number, and skip one. It’s a bit rough to get your head around at first, but once you see the pattern, you can understand why it’s not that bad. I did this for the first 8 columns of 9 LEDs, and used 9 pins to do it. You can see what I finally ended up with here (click for larger):

LED shield schematicSince I’m going with a non-square configuration, that made things a bit more complicated. What I ended up in the end was to wire the last 6 columns together in pairs. Remember that each pin can handle N-1 positive and negative connections. Since I was only using 8 of each, that left me with 3 positive and negative (6 total) connections to the first 9 pins I used. Being that there are 6 columns left, that worked out perfectly! I only needed to wire one connection to each of the remaining 6 LEDs on each row, as the other will get wired in series. I decided to wire the columns on the right in pairs together, because then you could theoretically drop off two columns to gain another general I/O Pin if you really need it. If you take a look, I’ve alternated between wiring the positive and negative connections. I ended up with this pin mapping.

So, what’s the next step you ask? I’m going to send off for this PCB to be made, and then I’ll build it. Hopefully I didn’t make a simple mistake, and this PCB will work just fine. If it turns out to work as well as I hope, then this may be a new kit. Once I find out that this works for sure, the PCB files will be released as well. I’ll also make sure to update once I get the PCBs in and built out.

{ 6 trackbacks }

Bicycle Info » Blog Archive » LoL shield proves that you can’t have too many LEDs
December 27, 2009 at 04:42
NEW PRODUCT – LoL Shield GREEN – A charlieplexed LED matrix kit for Arduino « adafruit industries blog
October 11, 2010 at 15:25
Kit Review – the LoL Shield « t r o n i x s t u f f
September 7, 2011 at 00:06
Kit Review – the LoL Shield « Hey it’s my blog…
September 7, 2011 at 00:25
BACK IN STOCK – White, Red, Green and Blue LoL Shields! « adafruit industries blog
March 7, 2012 at 17:42
The LEDs are on the wall | ANDREW O'MALLEY
October 5, 2012 at 16:19

{ 7 comments… read them below or add one }

1 Brett December 12, 2009 at 07:14

way to go man! I’m getting dizzy just looking at that schematic. there’s no way I’d get all the junctions right. I bow to your meticulousness.

2 josh w December 22, 2009 at 22:04

If you used kicad you might have been able to script things the design files are open and their isn’t a board size limit it is completly open source. So is the freerouter & schematic symbol maker online tool and java footprint module maker.

3 trialex December 23, 2009 at 05:25

Awesome – I’d definitely buy a PCB.

P.S. The “analog in” pins can also be used as digital pins. You just address them as digital pins 14 thru 19. This means you could charlieplex more LEDs, not that you could fit them on there anyways.

4 Jimmie December 23, 2009 at 10:36

Yep trilex, I purposefully left them open though. They can be used for I2C, analog input, general I/O, etc. Which makes them a little too useful to just run a few LEDs IMHO. There is still enough space for 6 more LEDs along the bottom if you want a few more in the existing matrix. ;-)

I thought about adding another row and column, but 10×15 wouldn’t really add much more, and you wouldn’t have any extra space on the board. I have a tiny prototype area along the bottom left, and spots to bring the analog and power pins further out.

5 Benjamin Sonntag December 29, 2009 at 10:55

Hi Jimmie !

the LOL Shield was a very nice project : I was very happy to program it under Linux, and thanks to your initial program, it was very easy.
The PONG I made is available here :
http://benjamin.sonntag.fr/a74-26c3_Day_2_A_Microntroller-based_led_panel_from_Jimmie.html

6 Joe September 1, 2011 at 06:15

Hi, firstly, amazing project! I was just curious to how you work out the resistor values for the LEDs, it seems complex, is there some kind of algebriac expression?

7 sdanks September 10, 2012 at 14:29

I wonder if the spacing would permit the use of chip LED’S? That would make it alot lighter for wearables. I realize it would be more difficult to solder, but if the pads are the right spacing, it might be more compact.

Leave a Comment

Previous post:

Next post: