LED Matrix Controller

A while ago, I got an LED matrix from SparkFun, and soon had it rigged up on a breadboard:

Arduino and 64 LED matrix

It could scroll any text I wanted, specified as a char array in the code. I had it working fairly well and decided to make a PCB for it…

A month or so later, the PCB arrived from BatchPCB:

LED Matrix PCB

LED Matrix PCB

I soldered it together pronto:

LED Matrix PCB

The resistors were a pain because there were so many, and the FT232RL was a pain because the pitch is so small, but overall I had no major problems and everything came together quickly.

PCB with an LED matrix plugged in:

LED Matrix PCB

Sadly I only have one LED matrix and SparkFun are all sold out of the medium sized RG ones; I’ve not been able to find them anywhere else either. While I wait for them to get back in stock, I’ll just work with one.

I was able to burn the Arduino bootloader code to the ATmega168 over the 10pin ICSP, and that worked fine, but then I ran into a few issues.

The first, and most prominent, was that every LED in a column lit up faintly when any of them were on. It turns out that this is because while my previous design had the cathodes connected to the shift register directly, the new design has transistors that pull the cathodes to ground. This means I have to write the shift register HIGH to get a low on the cathode. This was a an easy swap in the code.

The next problem was that the tops of each matrix were flipped over – row 4 appeared on row 1, row 3 on row 2, etc. This turns out to have been a problem in my circuit symbol for the LED matrix, I had the bottom 4 cathodes labelled backwards. Whoops!
Luckily this was easy to fix in software, so I soon had it all working:

LED Matrix PCB

However, this wasn’t the end of my issues. The ATmega168 is running at 12MHz from the FT232RL instead of using a seperate crystal and caps. However, the Arduino library expects the chip to be running at 16MHz, so all the serial timings are completely thrown off.

Luckily the ICSP header allows me to program it anyway, and this fits on next to the matrix, so it’s not a massive problem. This does mean that the computer can’t talk to the Arduino easily, however, which will make controlling it later a pain.

A bit of playing around in the software for the Arduino and I found a few defines I can set to get the Serial commands to run at 12MHz. This worked fairly well, I managed to get strings from the Arduino to the computer. All that’s left now is getting it working the other way, and ideally getting programming it to work.

I may make another PCB that is only through-the-hole and so easy to solder, using tinyUSB and just one matrix, possibly having them connect together. I could probably release this as a kit or similar, so watch this space!

30 Responses to “LED Matrix Controller”

  1. Could you post a schematic of the board? I have a r/g matrix that is gathering dust and I want to use it, but have no clue of where to start

  2. you can find them on ebay for $0.99 From seller cstevenson88

  3. Here’s an image of the schematic:
    https://randomskk.net/projects/led_matrix/rev06/schematic.png

    I’ll upload the Eagle BRD and SCH files when I get back, sometime tonight.

  4. could you also post your arduino code?

  5. Okay, I’ve uploaded the sch, brd and code:
    Eagle PCB layout:
    http://randomskk.net/projects/led_matrix/rev06/rev06_routed_silkscreened.brd
    Eagle Schematic:
    http://randomskk.net/projects/led_matrix/rev06/rev06_routed_silkscreened.sch
    Font header files:
    http://randomskk.net/projects/led_matrix/rev06/font.h
    Arduino Source (written as plain C, you need to remove the main() function and the WProgram include):
    http://randomskk.net/projects/led_matrix/rev06/led_matrix.cpp

    By the way – that eBay seller is indeed selling exactly the ones I want, but sadly only ships to the US!

  6. what would i have to modify to get it all into through-hole components?

  7. The schematic should be the same, but in Eagle replace all the surface mounted parts with through the hole variants.
    The board will probably require a redesign since the components are all different sizes but you can run tracks under resistors etc.

    The code should still work so long as everything’s wired up similarly.

    That said – why not try surface mounting? I was afraid of doing it at first, but after a small practise board I realised it’s actually not that hard and really fun to pull off, plus looks way better. Surface mounted components don’t cost much, so you may want to have a play on a small board and then perhaps try it out!

  8. I will have to try that sometime, I have already ordered my components through hole. I’m trying to make it as an arduino shield I will send you the board files after i am done and
    you will be able to do whatever you want with them

  9. speaking of wiring it up properly which pins on the 168 do you use in your code>

  10. Pins 8, 9 and 10 go to the shift registers.

  11. [...] the second matrix for my LED message board arrived [...]

  12. It appears on my led matrix that there are 8 anodes, and 16 cathodes. Would that make a difference to the schematic?

  13. I’m guessing that just means you have a similar matrix with inverted LEDs – instead of the common cathodes of my one, you have common anodes.
    The transistors will need to switch the anodes high to activate them, whereas in my design they are switched low – in other words the transistors need to be connected to vcc where they are currently connected to gnd.

    Other elements won’t change, though the software will need to write lows to the cathodes to activate them, etc.

  14. thank you, and also where did you get the library containing your matrix?

  15. I actually made it myself, but it’s just two rows of 0.1″ header pins (i.e. M12 in the Sparkfun library) with a custom symbol to connect to all of them at once.
    If you don’t want to make a library item it’l work fine to just use two M12 connectors and position them right, they fit onto the normal grid.

  16. wouldn’t i also switch the npn transistors for Pnp ones?
    I heard they were mere efficient for power sourcing

  17. you’re right, for sourcing PNP transistors should be used rather than NPN.

  18. Also the shift registers must be able to sink current – many can sink and source the same, but some are designed to only sink or only source.

  19. the ones that i ordered are tri-state, sink,source, and high impedance

  20. They should be fine.

  21. Hi Random. Would you by any chance be able to share your code? Mine is doing funky things and I’m getting frustrated haha. Thanks

  22. Sure thing, source code is at http://randomskk.net/projects/led_matrix/rev06/led_matrix.cpp and http://randomskk.net/projects/led_matrix/rev06/font.h

  23. thanks. how did you program your atmel chip? through the ftd232 on the board you made? I have a USBTINYISP programmer.

  24. I used the 10pin ICSP header in the middle of the board with my USBtinyISP. Going through the FT232RL didn’t work out so well, although that was my original plan. The ICSP method is faster anyway.

  25. oh never mind. i see you used the header on your board

  26. hey im tryiing to modify mine to do some midi type things like the monome project.. any think that might be doable?

  27. I’m sure that would be doable, though obviously you’d need completely different code. You could send the visual data over the serial port and then display it on the matrix, but the monome project uses buttons as well which aren’t on the matrix.

  28. how are you sending the serial data to the displays? Are you using ‘Processing’ or something? Thanks for the help!

  29. not sure why but i can’t get my ft232rl to upload either. hmm

  30. Try using a lower baud rate, I think the line or the clock is noisy so transmissions at high bauds get garbled.

Leave a Reply