The goal of this post is to document the design and programming of a small PCB with a 16×16 0606 RGB Led matrix, and microcontroller driver for the purpose of displaying graphics, animations, and text. While there are 0404 RGB LEDs on the market, the 0606 size is more affordable, and small enough to enable a 16×16 matrix to be made 4cm2. In an effort to keep the overall PCB small, I opted to direct drive the Led matrix with an ATmega2560 microcontroller.
The motivation for this project was to design a portable color matrix to display simple video game sprites and animations on, and to have it small enough to be worn as a badge for the upcoming MakerFaire. It was a fun reason to design a 4 layer board in Altium Designer, and also to get experience using solder paste and stencils to solder tiny SMD parts.
The PCB is 4 layers, with the top side consisting of the Led matrix, series resistors, and microcontroller, and bottom side for bypass capacitors, 16MHz crystal, and micro USB connector. A ICSP breakout is provided to flash new firmware to the microcontroller via an AVR serial programmer, and the micro USB connector is provided to power the device. There is a linear regulator section on the top of the board that was made in an attempt to power the device with a battery, but this did not work out and these pads are left unpopulated. In the end, I powered the device with a small USB power bank, which provides regulated 5V and the required peak amperage.
The Microcontroller drives the matrix using two ports for each set of 16 row cathodes for Red, Green and Blue, and 2 ports for the 16 common cathode column connections. The middle two layers of the PCB are used to provide area to route the many connections from the microcontroller to the color row anodes. The bottom layer has a ground plane and common cathode connections between each column of LEDs. The top layer has the three common anode connections per row of LEDs.
Below is a 3D video rendering of the board in Altium Designer. The board is 4.4 cm x 7 cm.
When I design a board for a personal project I like to add interesting silkscreen art because I can, and this time I went for an astral luna moth which turned out beautifully on the black soldermask.
I had the boards manufactured by Elecrow PCB prototyping service, and they came out exceptionally well and at a great price for ten of them.
The first board was completely hand assembled with needle point tweezers, thin solder, and a lot of patience. After spending 3 hours or so on one board I opted to order a solder stencil from OshStencils, and that cut the assembly time down to an hour.
At 16MHz, the microcontroller is capable of driving the display comfortably above the flicker fusion threshold. Software implemented PWM allows for 8-bit color to be realized on the display. While constant current driving of the matrix would result in a more consistent brightness and color, the necessary driver chips would have limited how small I could make the PCB. Despite being direct driven, for the general purpose of displaying the types of graphics I need it to, it is more than capable.
A Python script is used to take in a 16×16 (or other dimension) image file and output a text file with the C byte array of the 8-bit color data for the image that is used to display the graphic on the board. This allows for artwork to be prepared in a pixel art drawing software and easily converted for display on the device. There is a general function that is used to display a 16×16 graphic for a certain period of refresh cycles, and this can be used to string together frames for an animation.
Other display functions are capable of scrolling graphics across the screen to achieve even more complex animations such as Pacman being chased by ghosts, or Nyan Cat flying across the screen.
The source code for the project can be found here. The youtube video at the beginning shows most of the animations I displayed while wearing the board as a badge at MakerFaire. The display is very brilliant, and I had to darken the video to allow for the colors to display naturally.
One thought on “Tiny 16×16 RGB LED Matrix”
That circuit board is a beauty! Very well designed and really impressive. I want to learn how to do what you can do. Can’t wait to see more.