I have built several LED projects for customers. Building on that experience, I created a large 60x32 LED Matrix.
I am certainly not the first person to think of using addressable LED strips to create a display. However, most of the existing projects use the display as a simple sign, slide show viewer, or low-res video wall. I wanted to do something more interactive.
To that end, I wrote a game engine specifically for the LED Matrix. I then solicited programmers and game designers to create unique games specifically for the Matrix. I wrote an emulator for the Matrix in the Processing environment so that developers could write games for it on their own computers without needing to have the hardware. The end result of that project was six amazing low res games.
The LED Matrix has been exhibited at:
- SXSW Create (March 11-13, 2016)
- Austin Maker Faire (May 7-8, 2016)
- Classic Game Fest (July 30-31, 2016)
- Juegos Rancheros (September 1, 2016)
- Fantastic Arcade (September 26-30, 2016)
- EFF Austin (March 11, 2017)
- HavenCon 3 (April 20-30, 2017)
- Maker Faire Popup at the Bullock Texas State History Museum's exhibit "Pong to Pokémon: The Evolution of Electronic Gaming" (December 28-30, 2017)
- Austin Maker Faire Mixer (February 15, 2018)
- San Antonio Mini Maker Faire (March 24, 2018)
- Various events, concerts, and music festivals around Austin, TX
Here is gameplay video for the six games created for the LED Matrix.
At Fantastic Arcade 2016, I participated in a panel on "Making Games on Weird Hardware".
Here is the video. Most of the information in it is also below in text format.
I got the Idea during Fantastic Arcade 2015, when I saw a very cool little LED-based game. I thought I should make one too so I talked to Wiley Wiggins, the organizer of Fantastic Arcade and Juegos Rancheros, and he encouraged me to do it. As I mentioned above, I set out from the beginning to make an LED game system, not just an LED sign. I think this is the first one, but I hope other people will be inspired.
I wanted to display it at SXSW Create, but it was not finished in time, so I took it to the expo and worked on it there. It is a maker event, so I thought why not make something live. At the end of Create, I powered it on, and it worked!
Two months later, I took it to MakerFaire. It was fully functional, but I had not yet begun the game engine. I just had a simple bouncing ball that was displayed over top of a plasma demo program written by Edmund "Skorn" Horn.
Next, it was on display at Classic Game Fest. I had started work on the video game engine, but it was in its early stages. The bouncing ball was now a true sprite. I had built the controller, but did not have the hardware working on the Matrix side. So, I bought an old Atari 2600 controller at the Fest and wired it directly to the microcontroller in the Matrix so that I could build a rudimentary game.
Over the summer I finished the game engine and had written a demo game called Super Dodgeball. I also wrote a second game, Rainbow Collection, that was designed by my friend Bradford Kinney. I took the Matrix with those two games to Juegos Rancheros to recruit more developers, and signed on two devs.
By the time Fantastic Arcade 2016 rolled around, two other friends ended up writing games for it also. You can see read about all six of their games below.
Click the pictures below for detailed views of the front and back of the Matrix.
The LED Matrix hardware is based on off the Shelf LED Strips, AKA NeoPixels (Adafruit name). They are 5050 SMT LEDs with a built int WS2811 PWM Controller soldered to a flexible circuit board. These LEDs can be very easy to use, but also come with challenges. One challenge is that the one-wire serial protocol requires very precise timing. It is only practical with a dedicated microcontroller. Anything with an OS, like a Rasberry Pi will not work because the built-in multitasking will interrupt the serial communication.
Another issue is their high power consumption. The three LEDs (red, green, and blue) in the pixels have their brightness controlled by PWM (pulse width modulation) by the controller. However, each pixel is independent, so they can all be on at the same time, and all drawing current. To drive 1920 pixels at a maximum of 50 mA each, you need 97 Amps. While it is rare that all LEDs will be at full brightness at any one time, I did not want to skimp on the power. So, I used a 100 Amp power supply. Specifically, this one. At $77 it is not cheap. It draws up to 12 Amps from a 120V AC circuit, so it can easily trip a breaker if you are not careful.
The high current brings another challenge in that the rather thick 22 AWG wire has to be soldered to the tiny and thin flexible PCBs. The gauge of wire needed depends on the number of LED strips per power wire. I ran wires from the power supply to distribution strips and separate wires to each strip of 60 LEDs.
The strips themselves are adhesive backed and are stuck to a piece of blackboard material. There is also a frame that holds it all stable and allows for mounting of the power supply and control hardware (in a protective plastic enclosure).
Sometimes pixels go bad. One of the three (red, green, blue) LEDs inside them stops working, or is stuck on, or is the wrong color or brightness. They can also stop working entirely. That causes all LEDs that come after them on the strip to stop working because each pixel relays data on to the next one. If a pixel dies, then it has to be cut out of the strip and replaced. It is not much fun to do. You have to create a solder bridge across the cut strips. I had about five pixels fail within minutes of powering on the matrix. Other pixes failed over time. It seems that there is no way around doing periodic maintenance on an LED matrix.
The display is controlled by a Teensy 3.2 Microcontroller board. It is an Arduino compatible, 32-bit, 96 MHz MCU with 256K flash program memory and 64K RAM, and it only costs $19. That is a lot of bang for the buck. But, the real reason to use a Teensy is the OctoWS2811 library.
A quick Google of LED matrix will turn up several projects. The largest of them all use a Teensy with the OctoWS2811 library. The library is written by Paul Stoffregen, the creator of the Teensy. What is amazing about this library is that it can provide eight simultaneous serial outputs using the on-chip PWM peripheral and DMA (direct memory access). The upshot of that is that the library can read the display data from memory and send it to the LEDs with barely any CPU cycles. That leaves the full power of the MCU chip at your disposal. It is so fast that you can get a 120 FPS (for 2000 LEDs) refresh rate!
PJRC (maker of the Teensy) sells an OctoWS2811 Adapter Board which has a 74HCT245 voltage level shifter/buffer chip, two RJ-45 jacks, and headers to hold the Teensy. The purpose of the RJ-45 jacks is because the communication to the LED strips is over CAT6 ethernet cable. Ethernet cable is perfectly suited to the task because it is designed for high bandwidth signals at a fixed impedance.
Follow both of the OctoWS2811 links above for lots of information about building an LED Matrix.
A game system needs sound. I used a Dream SAM2695 General MIDI synth chip and a custom circuit board of my own design. The Teensy talks to the sound chip via a simple serial connection. It would also be great if the Matrix could play samples. It does not currently do that, but that could be added without too much effort. A MIDI chip does give you a lot of sounds to choose from, for both music and sound effects.
The controller has 16 Lighted arcade-style buttons housed in an aluminum enclosure. The buttons are read by a little PIC microcontroller and the data is transmitted serially to the Matrix. There is an RS-422 transmitter chip in controller and a receiver chip in the Matrix. A differential signal is transmitted over twisted pairs (ethernet cable again) for reliability and maximum cable length - up to 50 feet if you want. I don't use that long a cable, but I have a vision of mounting the matrix high on a wall in warehouse installation and controlling it from the ground.
Game Dev Library
To make it easier to write games for this weird custom hardware, I created a game dev library. The library includes functions to:
- Communciate with the controller buttons
- Communciate with the sound hardware
- Update the whole screen from a buffer
- Draw graphics primitives (line, rectangle, ellipse)
- Draw sprites
The sprite library is fairly full featured. The sprites are 2D. The hardware is powerful enough for 3D, but the display is just too low-res for that to work visually. The sprites themselves are palated. The pixel data and color data are stored separately. That enables you to reuse the same pixels with different colors - an age-old game programming technique. They also feature transparency, which is necessary so that the background, or other sprites show through the transparent areas. There are collision detection functions built in as well.
Finally, I wrote a utility to convert image files (bmp, png, jpg) into data arrays that are easily pasted into a game program. The image conversion utility is written in Processing (for the same reasons outlined below).
To have multiple programmers writing games for the LED Matrix without having the hardware, I wrote an emulator. The emulator is written in Processing. Processing runs on any platform (Windows, Mac, Linux). It is also built for graphics and sound, so it contains all the needed image manipulation and MIDI functions.
Processing programs (called sketches) are written in Java, while Arduino programs are written in a version of C++. Since Java is a descendant of C++, the two languages are syntactically similar. It is fairly easy to translate programs written in the emulator to the Matrix. Theoretically. How easy depends on the programmer. If you know that your program is going to be translated and you know some C++, then you can ease the translation. Do not use Java-specific data structures, or rely on Java's built-in garbage collection (which does not exist in C++). There is more about the development of the Matrix gamess in the Fantastic Arcade panel video above.
The game loader uploads programs into the Matrix (I love saying that). Games are written in isolation, and do not take into account that multiple games might be in memory at once. Therefore, only one game at a time can be loaded into the Matrix. This is accomplished by sending the compiled game from a laptop to the Teensy over a USB cable. Running on the laptop is the Teensy loader program and a custom app with a simple one-button-per-game interface.
It is incredible what creative people can do with just 60 by 32 pixels! Each game is completely different and totally amazing.
Written by Mickey Delp
Super Dodgeball grew out of the development of the game engine. I needed to test each routine as I wrote it. This game makes use of the sprite functions, animation, palate shifting, collision detection, displaying numbers, the controller interface, and sound. I gave the Super Dodgeball source code to the other developers as an example. The game is very simple, but surprisingly difficult and fun.
Designed by Erin Parr, Programmed by Mickey Delp
All sprites are hand drawn, then scanned and reduced. Each of the characters has it's own unique movement and animation. The map of the undersea world is edited in a spreadsheet which has letters to indicate the positions of objects and characters. The spreadsheet has formulas that convert the map to arrays that can be quickly copied and pasted into Processing to test the game.
Designed by Bradford Kinney, Programmed by Mickey Delp
Rainbow Collection is inspired by Choo-Choo Rocket. Two to four players can play simultaneously. It is very fast paced and frenetic.
Written by Kevin Welch
Fakeout is a Breakout-style game with some really interesting twists. To eliminate a brick, the ball has to be the same color. You set the color of the ball by switching the color of your paddle. You can rotate the bricks right or left to line them up with the ball. The game starts slow, but quickly gets super difficult. With each level, the paddle and bricks get smaller, the number of rows of bricks increases, and it gets faster. It is also the only game so far with a theme song.
Written by Kevin Sun
Kevin saw the Matrix at Juegos Rancheros and volunteered to write a game for it. He wrote a Rogue-like game. It is so authentic to the original text-based version, that the sprites are ASCII characters. This game is very creative. The retro esthetic is super cool, the movement and battle mechanic is very intuitive, and it is a blast to play.
Written by Randy Smith, Translated to C++ by Randy and Mickey
Randy also saw the Matrix at Juegos Rancheros and really dove into it! The game is a beautiful multi-level D&D style game for one to four players. This game is very deep. Each character and enemy has health, strength, and experience levels.