Recently, I was offered the opportunity to give a workshop and attend a lab opening at a university. I always love going out to universities and talking to students about electronics, but this time I was a little nervous. Normally, I just take a few demos of whatever I've been working on lately to show off to the students. Toward the end of the summer I had started working on hacking an induction cook top to complement my IoT Sous Vide, which I was planning to bring to this university. However, at the last minute I found out they already were planning to show some cooking hacks at this event. Somehow I needed to come up with something that I could quickly build (<24 hours) that would "blow the students away" (quote from the big boss...). How in the world could I hack together a demo in the time that I had that would truly impress my peers in education? Stay tuned to find out.
In a last ditch attempt to help me come up with a fun demo, a friend gifted me a pile of 8x8 RGB LED modules from Olimex. These are really fun little displays that can be easily daisy chained and driven with SPI. I wasn't sure what I would do with them, so I started scouring the internet for other fun projects that used similar displays. After looking around I found a game of Snake that was written to use one or two bi-color 8x8 LED matrices and an Arduino.
This seemed like a cool project, but didn't fulfill the "blow students away" requirement. I thought about it some, and I figured that I could reasonably easily make the game more engaging my adding my own flair to it.
I started out by hooking a single display to my TM4C129 LaunchPad. I chose this LaunchPad because it has two sets of BoosterPack headers. This would allow me to connect the display and another accessory. To get started on the software, I took the original Arduino code from the Jollifactory Instructable, and started modifying it until it would compile on the LaunchPad. Then I added the driver software for the Olimex display. This required quite a bit of software rework as the way the display was driven in the Arduino project was completely different from these Olimex displays. After taking some time to understand the differences between the two I was able to tweak a single function in the software such that these new displays worked properly. At this point I had a single panel snake game with no controls.
Since I was low on time and I needed a playable game, I started working on building a wireless controller for the game. I immediately grabbed my new Educational BoosterPack MKII as I knew this would be a great foundation for a game controller. I combined this with a CC110L BoosterPack and MSP430F5529 Launchpad. For the software I combined the Educational BoosterPack Joystick example with the CC110L Wireless Sensor example to form the firmware for the controller. After some quick debug, I was able to send commands wirelessly from the controller and print them out using the serial console of the TM4C129 LaunchPad. Next, I tweaked the game software to use the wireless radio to process the commands from the controller and turn them into actions in the game. Finally, I was able to play a game of Snake wirelessly!
Playing with my snake game was a lot of fun, but the display area was limited. I wanted my snake game to be bigger and more engaging than the other snake games out there. I had to have the best snake game of them all!
To this end, I knew I had to expand the game so that it would run on all 10 displays that I had been given. I did this in a systematic fashion as to maximize my chance of success in the limited amount of time that I had. The original software was written to handle only 2 displays, so the first step was to get that second display running. After adjusting the code as the comments indicated, the game wasn't being displayed properly. I figured the culprit was the display adapter software that I had written earlier. After importing the Energia sketch into Code Composer Studio and doing some debug, my suspicions were confirmed. A few quick tweaks and I was able to get the game running on 2 display modules. This success led me to up the ante to 5 display modules. Once again the code required a few minor tweaks, but ultimately adding those 3 additional displays in a line arrangement was very straight forward.
At this point, I had five display modules connected end to end giving me a very long and narrow playing area. I needed the playing area to be much thicker so the game would be more enjoyable for the player. To accomplish this, I planned to add another 5 displays next to the original such that the playing field would be 5x2 displays. From a hardware perspective this was as simple as daisy chaining the additional displays, but the software was another story. The software was originally written to have a maximum playable area of 8x16 LEDs and because of this some of the logic in the game was hard coded. In this final iteration of the software, I modified this hard coded logic to allow the user to specify the number of LED modules in both the X and Y directions. This should effectively allow the user to have a snake playing field as large at they want (barring any timing issues with the SPI communication). After a little debug work, I was able to get all 10 displays working! I now had a HUGE snake game.
Now that the core game play was complete, I focused on cleaning up the overall game experience. I added a title splash screen and some logic to keep track of score. When the game ends, the users score is displayed.
Since this is an RGB display, there is a lot that can be done to enhance the game play. In the future I intend to add some power-ups/downs to speed up/slow down snake movement as well as give the user bonus points.