RGB LED Pocket Gamer

.jpeg)
A pocket-sized gamer that uses an 8x8 RGB pixel matrix to play Snake, Flappy Bird, and any other retro games you can design.
I think bright RGB LEDs look great, and wanted to create something that showcases them. I started with the classic game of Snake and ended up with both Snake and Flappy Bird, all programmed with minimal components.
I'll also go over programming and soldering as well for such tiny powerful components!
Supplies


I’ll start by listing the tools I use: a hot plate, a UPDI programmer, and basic soldering supplies.
Tools
110V 850W Soldering Hot Plate (this one is big - i'm sure a small one would work)
Stencil Squeegee (I think mine is a bakers frosting tool)
Supplies
ATTINY1616, the chip! - $0.90 USD
0.1uF and a 10uF 0603 ceramic capacitor, power filtering - $0.16 USD
6 10k resistors 0603, pull ups - $0.60 USD
4 6.00mmx6.00mm buttons - $0.48 USD
1 Surface Mount button - $0.48 USD
1 P-Channel MOSFET, battery protection - $0.42 USD
1 Power Switch - $0.72 USD
1 CR123A Battery Case - $2.25 USD
**I did not use these** 2 100uF, power filtering. The LED matrix asks for an electrolytic capacitor due to the potential quick and high current draws when many LEDs are turned on at once. This gamer only lights up a few LEDs at a time (unless you're good at Snake ), so I chose not to use a capacitor. I ordered these MLCCs high quality capacitors since I didn't love the idea of a surface-mount electrolytic capacitor sticking out. That said, I haven’t tested or installed them. I have tested this board for hours and mine works with out them.
1 Adafruit DotStar High Density 8x8 Grid, - $25 USD. Yep $25 clams… These are awesome matrices that will save a lot of work but at a cost. With a hot plate, you can also remove them and reuse them for another project. I do plan on trying to build my own multicolored, lower-power, cheaper LED matrices. Look out for that in future builds.
The board will be provided below, but you can also use a breadboard. I’d recommend picking up a https://www.adafruit.com/product/5690 for a breadboard.
The Board and Its Programmer

.jpeg)


This project is a good example of a bare chip that is powerful and easy to program. This final board will have five buttons, four for gameplay and one to switch between games.
You can order the board here. Make sure to get the stencil as well. Or design it with a bread board.
This blank chip can be programmed using a UPDI programmer in the Arduino IDE environment. Follow the excellent steps provided by Adafruit.
On the back of this board, there are three pads: Vin, Gnd, and UPDI programmer. I solder three separate male headers onto these pads. I use clay to help align the headers when I solder. Look at the pics above. Soldering and Assembly step below for more detailed build instructions.
Programming
Follow the directions from Adafruit, but I will summarize:
- In Arduino, add the following URL to your Boards Manager preferences: http://drazzy.com/package_drazzy.com_index.json
- Install megaTinyCore from the Boards Manager.
- Under Tools, select:
- Board: megaTinyCore: ATtiny1616
- Chip: ATtiny1616
- Clock: 10 MHz
- Programmer: SerialUPDI - SLOW: 57600 baud
- Finally, go to Sketch > Upload Using Programmer. Upload a blank sketch to confirm it works.
You should see your UPDI friend blinking and the code being successfully uploaded to the board. If it doesn’t upload, the most likely culprit is that the chip wasn’t soldered properly. Soldering tips below.
Soldering and Assebly
.jpeg)
.jpeg)
.jpeg)

This "wisdom" comes from a combination of armchair research and practice. There may be better ways to build this board as I'm still learning.
Use common sense and be patient!
- First, align the stencil over the board. Put solder paste over the holes and push the solder in using a squeegee. Make sure everything is flush and clean.
- Contrary to online comments (people use too much solder paste), I actually found I didn’t have enough solder on my ATtiny1616 board and footprint. To get more solder onto the chip's pads, I pressed the ATtiny1616 into the solder paste like I was prepping it for the hot plate. Then I reapplied solder paste to the board using the stencil and squeegeed really well again. I ended up with some solder paste on the bottom of my chip and fresh paste on the board.
- The other components are relatively easy. Place the pieces on the solder with tweezers. My favorite tweezers are plastic tipped.
I would not put the LED matrix on yet. Check that the cheap stuff is working first.
- I place my board, with the pieces and solder, on the hot plate while it's off. Turn on the hot plate and wait for it to reach 215°C. You can watch the solder melt around 200°C. Again, this is what I found works. As soon as it hits 215°C, I turn the plate off, carefully grab the board with needle nose pliers, and move the board to a cooling metal tray (like a cookie sheet).
- I had solder bridges on the ATtiny1616. Personally, I'd rather have solder bridges than not enough solder. Put some flux on the bridges, grab a hot soldering iron, and gently drag the iron across the bridges. I use the side of the chip as a guide. See the bridges turn into nice pad connections. Clean off the flux with alcohol and Q-tips. Burnt flux is sticky and yellow-brownish. Also clean the tip of your soldering iron with solder and a wet sponge.
- If you look very closely at the ATtiny1616 sides you can actually see whether a pad has made a connection. On my first board the ATtiny's UPDI pin didn’t connect and I couldn’t program it. Look at the pictures above. Luckily, I hadn’t soldered the LED matrix yet, so I was only out a dollar or two started over.
- I also check continuity with a voltmeter. The test that beeps when there’s a connection. I always check Gnd and Vin are not connected, because stuff will smoke and burn :)
- After the board can be programmed (see above step), it’s time for the LED matrix. I broke off the side tabs of the LED matrix and put a little solder on the board’s blank pads. When looking at the front of the board and going left to right, the pads are: SCK (clock), MOSI (data in), GND, and VIN. I designed the board so these pads align nicely with Adafruit’s matrix.
- **Make sure you use the matrix's data in and clock in pads with the board's MOSI and SCK**. I think if you use data out and clock out, it won’t work.
- Place the matrix on the pads with solder and back to the hot plate. Take off at around 215°C.
The Code

For me, the code is as fun as assembly. I wrote versions of Snake and Flappy Bird. My favorite part is the gravity simulation in Flappy Bird. How cool that this 90-cent chip we just blasted to 215°C is doing a gravity simulation and running Flappy Bird! Try writing your own games and uploading them via the programmer. I had started a version of Chrome's Dino game. Pong and Frogger could also work.
The code isn't too hard to follow and uses simple C++ classes.
These are the libraries I used and maybe this will help justify the $25 LED matrix. We can write to an LED (pixel?) using a full, tested graphics library from a reputable company. With just four common libraries lighting up a pixel is as simple as: matrix.drawPixel(x, y, color);
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_DotStarMatrix.h>
#include <Adafruit_DotStar.h>
#include <Fonts/TomThumb.h>
Working code also shows the power of the ATTiny1616. What was a blank chip is now able to run adafruit's graphics code!
Downloads
Finale
.jpeg)
Solder the through hole buttons, battery holder, snap in a cr123a battery, and play!
My flappy bird high score is 31, even tho I haven't come close to it in days.