For my final project, I was tasked to create a custom Arduino Mega shield that makes use of 1 shift register (74HC595) and an 8x8 LED matrix. Instead, I decided that I wanted to play Tetris on my Mega, so I added an additional shift register and LED matrix to be able to play a 16x8 version of Tetris!
This project was a very large multi-step project, where I would have to plan, design, and create everything on my own. I did these 4 steps to complete the entire project:
- Design the entire schematic
- Create the PCB
- Solder components on to PCB
- Code the Mega to play Tetris on it!
After these 4 steps, I would successfully would have finished the project, and this is what I followed to bring it to fruition.
So, time to create the schematic so that I can figure out where every component belongs! I used an open-source program called KiCad, which is a very beginner friendly and easily accessible program for what I needed to do. I also noted a few things to get this schematic finished:
- Use pins 22-53 (the very back pins on the Mega) and select pins on the same port for easy inputs/outputs
- Using 2 shift registers instead of one, meaning I would have to utilize 2 Slave Select pins in the SPI (Serial Peripheral Interface), 1 Master Out Slave In, and 1 Clock to control both of them
- Create a custom LED Matrix component for the schematic (since it did not exist before!)
So, that is exactly what I did. I extracted a pin header with the exact 2x18 format that the Mega contained, so that I could wire everything to that. I made sure that the parallel outputs were all on Port A, for easy outputting. I did the same for the inputs. Since I figured out I was not going to be using the SPI.h library for this project, all I had to do now was connect all the pins I had left in any configuration to the shift register. This includes the slave select, clock, power, input, etc. Creating the LED Matrix was a piece of cake, just an 8x8 square with pin inputs on them. Then, I connected the 8 outputs of 1 shift register to an 8x8 matrix, and did the same for the other shift register. I placed current-limiting resistors for the LED matrix so the LEDs don't explode, and also connected pull-down resistors to the inputs I would be using to control my Tetris game! I also added a speaker just for fun. The final result is this:
Next up, it was time to design the PCB! Looking at the schematic, I made sure that each symbol had a corresponding footprint so that each component would be accurately drawn on my PCB. This is when I also created a footprint for my 8x8 LED matrix, by taking down its dimensions, distance from pins, and custom designing the footprint. I generated the netlist from the schematic, so that when I opened the PCB viewer, I would see every component (in blue/yellow) and every connection (in white lines). It looked like this:
Looking at this again gives me a headache. Anyways, after sorting and tinkering and rearranging and trying to fit everything into a PCB that is 12.5cmx4.5cm (for cost purposes), I finally came to the final design (move right to see less tracks):
1 / 4 • Red And Blue Traces!
It only utilizes 2 layers, with red going left to right and green going up and down. I also made use of multiple vias, because without them, this entire PCB would have been impossible within those dimensions. The yellow represents the final board shape, big yellow circles are where pin inserts would be, and everything that is blue just shows where the footprint would appear in real life. The real 8x8 LED matrix will be extruding a bit out of the PCB, so its silkscreen is not shown. Looking back, I can not believe I got this to work and I am very proud of myself! Yay!
Front and Back using 3D Viewer
After the designing process, it was finally time to get to manufacturing! I exported the gerber file, and used a website called pcbway.com to get it manufactured. When we got it, it looked even better in person than it did on the software. Unfortunately, I only have the soldered version, so here it is:
The pins on the back fit perfectly onto the Arduino Mega. This is my first time soldering a PCB, and I had a very straight forward time. I completed the shield! Now, all there is to do is to code it. It took a while, but it was just like coding regular Tetris. I put the code in the description, so you can check it out yourself.
And there it is! A fully completed and functional Tetris game on the Arduino Mega! This was a lot of fun creating, and it felt more like a personal project for me then a final project for school. I learned a lot from this project, and designing and creating this PCB was amazing. I think this is a very beginner friendly project, and with little knowledge or experience you can make something like this as well!