This is a write-up on my Arduino based hand-held gaming device. I realize it’s a somewhat poshy statement but hey, it is Arduino based, it’s hand-held and it’s a device that plays games!
Step 1: A Hand-held Gaming Device...
The device sports a couple of games and a menu system consisting of a letter indicating the current selection. The menu options may be selected by turning the dial and the corresponding game is started pressing either one of the push buttons. When the game is finished playing it returns to the menu system allowing the user to immerse herself in yet another one of the many exciting gaming experiences the AbHhGD has to offer!
Step 2: The Parts
To build this little hack requires just a few parts:
- Arduino Nano/Uno.
- Max7219 LED matrix.
- Mini bread board.
- Two push-buttons.
- 50K Potentiometer.
- And of course, some jumper wires.
Step 3: The Wiring
The LED matrix already contains a Max7219 LED driver chip so wiring it is very easy. Five wires is all it takes and each of them go to the Arduino. The attached sketch expects the following pins:
- VCC - 5V
- GND - GND
- DIN - D12
- CS - D10
- CLK - D11
Step 4: The Controller
Then the controller stuff: the potentiometer is wired to 5v, ground and analog port #1. The buttons are wired to ground and respectively D4 and D5. I used the Arduino’s internal pull-up resistors to pull the in-ports high. Since the game loop runs rather slow there’s no need to bother with debouncing so I didn’t bother using any capacitors, although a 10uF capacitor between the potentiometer’s middle pin and ground might take care of some occasional jerkiness in the dial’s readings.
Step 5: The Games, the Code
The games, six of ‘m as of yet:
1. Good ol’ Pong, the well-known infinite loop [Bounce the ball with the paddle. Wait for the ball to return. Repeat]. I’ve put in a very rudimentary level-up strategy, mainly to keep me from going insane while testing during development: everytime the ball hits the paddle a level-up-counter goes up by one, every ten level-ups the game runs a little bit faster. After two times going a bit faster two bumpers appear in the playing field. If the player even survives that ordeal for ten hits in a row the paddle shrinks by one dot. This repeats until the paddle has shrunk to no paddle at all.
2. Tedshow. A regular feature in a rather moronic quiz show called “De Ted Show” which was aired during the early eighties in the Netherlands would require the winner of the quiz catching some sticks falling randomly out of the ceiling to determine the prizes he or she would win. The game is as brain dead as the quiz show I’m afraid.
3. Space Invaders. This true classic features some of the most effective A.I. in gaming history: [Keep moving left, until hit wall. Move down. Keep moving right, until hit wall. Move down. Repeat]. Due to scarce real-estate however, I modified it a bit in having the invaders bounce to and fro a couple of times before moving down. The player is allowed to fire a single bullet at the time, as are the invaders. Starting with two rows of invaders, each level-up adds another row. Again, scarce real-estate forced me to refrain from adding a fourth level. Guess I should have put in a boss-level..
4. Snake. Turn left and right using the push buttons. Eat apple, snake grows and moves faster. Don’t bite yourself!
5. Break-out, or Pong with obstacles.
6. And of course, no gaming device is complete without a racing game!
The sketch contains a number of different units. Some of those units in turn consist of both a .h (header) file and a .ino file. The should be rather self-explanatory and is full of comments to clarify.
Step 6: The Casing
Finally, a nice container would add to the portability of the handheld gaming device :-)
I started out with a little plastic container. The lid would fit the LED matrix and the buttons and dial. I made a square hole in it and hot-glued the LED matrix fixed. I swapped the Arduino Uno with a Nano and had to bend the Nano’s pins to make it fit the container. I used a lot of hot glue to prevent the pins from shortening with any metal parts inside the container. The buttons are hot-glued to the case as well and the potentiometer would fit nicely through an M6 drilled hole.
It is somewhat bulky, especially with the 9v battery container hot-glued to the back, but certainly a handheld gaming device now it is!