For other interesting ARDUINO PROJECTS here
Our Retro Gamebox is built into a see-through container.
Our Arduino microcontroller doesn’t come with a video output, although we showed you in the TV Weather Channel Station Project how you could hook it up to the composite video input of your TV and display your own TV weather channel.
So for this project, we’re combining all this knowledge and putting together our very own retro arcade games console we’re calling the Retro Gamebox.
What you need
Apart from the Arduino Uno board, the main components you’ll need are the arcade-grade joystick and fire pushbutton. They look impressive, but they’re not expensive. We picked up ours from eBay — the joystick for $8.79 and the pushbutton just $3.50, both including shipping.How the single-fire pushbutton works is pretty straightforward: the button plunger operates a normally open (NO) microswitch, which closes when the button is pressed. A nice extra is that many also have an LED inside the button top.
The joystick is a little more complex — it has four NO microswitches, one for each compass direction, which operate as you pull the central control around. Some arcade joysticks have a mechanical locking mechanism that will lock off one axis (X or Y) so you can use it more easily; for example, locking off the Y axis so the controller becomes a side-to-side type for playing Space Invaders.
Whether you’re building a full-on replica arcade gaming machine or just our little Gamebox, the joystick switches do the same job: they connect to the circuit board and when activated, cause the software to change operation based on the switch(es) pressed.
So that you can see the insides of our design more easily, we’ve gone for a basic see-through food container. If you’re really keen, you could put the whole thing together into your own full-scale retro arcade machine.
Parts list | ||
Part | Cost | Source |
Arduino Uno R3 | $13.20 | eBay |
Eight-way arcade joystick | $8.79 | eBay |
Arcade pushbutton | $3.50 | eBay |
Dupont wires | $2.55 | eBay |
Red RCA socket | $0.95 | Jaycar |
Black RCA socket | $0.95 | Jaycar |
900ml kitchen food container | $2 | Local $2 shop |
2 x 470ohm 0.5W metal resistor | $0.46 | Jaycar |
1 x 1kohm 0.5W metal resistor | $0.46 | Jaycar |
TOTAL COST | $32.86 |
Games
The inspiration for this project of ours came from the Hackvision system developed by Nootropic Design. It’s a basic cut-down custom Arduino with four direction buttons and a fire button, all built onto a single printed circuit board. You can buy it as a prebuilt device ($44) or a kit you put together yourself ($34). However, since the Arduino code for a number of games — including Space Invaders, Asteroid, Tetris and Sudoku — has been released to open source, we decided a game box with existing Arduino hardware would be a worthy inclusion into our project list.The main problem with the Hackvision system is the lack of USB connectivity, requiring you to come up with your own USB-to-TTL adapter cable to program it. By using a standard Arduino in our Retro Gamebox, changing games is as simple as plugging the Gamebox into your PC’s USB port and compiling the new Arduino sketch.
How it works
Our Retro Gamebox is surprisingly simple when it comes to hardware: five switches, three resistors, a couple of RCA sockets and that’s about it. Well, it’s a little more complicated than that, but when you boil it down, that’s all there is from an electronics viewpoint.How the arcade joystick works
Four of the five switches belong to the arcade joystick. Mechanically, an arcade joystick is just a centre bolt that pushes the actuators of four microswitches wrapped around the outside. Each switch has two connectors: the contacts are the NO type that close when you move the joystick and actuate the switch. The trick with arcade joysticks is they operate the opposite switch to the direction of movement. So pushing the bar up activates the bottom switch; pushing it left operates the right switch and so on.Arcade-grade controllers use four microswitches around a central control lever.
In the Gamebox, the digital inputs these switches are wired to are set to activate when the switch pulls that input to ground (the 0V rail). That means we can join one connector of each microswitch together and wire it to ground, creating what’s called a common ground. This allows us to use just five wires from the joystick to the Arduino (one for each switch and the common ground), instead of eight (two for each switch).
For other interesting ARDUINO PROJECTS here
How the fire button works
The fire button works slightly differently — it has just the one switch, but two modes of operation. The switch has three connectors: a common connector plus one that’s NO and one that’s normally closed (NC). With the switch resting, the common pin is electrically connected to the NC pin. When you press the switch, that common pin then connects to the NO pin and disconnects from the NC pin.The switch we’ve used here also has a built-in LED and current-limiting resistor. What we’ve done is hook up the anode side of the LED to the Arduino’s 5V pin and the cathode side to the pin that connects the switch to the Arduino (D10). The result is that the LED lights up whenever the fire button is pressed. Combine that with the blue power LED on the Arduino board and you get a neat little light show.
A good-sized fire button is a must-have for any games console!
Video/audio output
Thanks to some impressive coding from Myles Metzler and others, the video and audio output that connects to your TV requires only three resistors and one of those is optional. We won’t cover how it works here, but briefly, composite video requires two electronic signals: the analogue video data plus the synchronisation pulses that tell the telly where the data is meant to be on the screen. Two resistors are all that’s required to combine the signals into one composite video output with the correct voltage ratios your TV will understand.The Gamebox features composite video out and 8-bit sound via its two RCA ports.
For other interesting ARDUINO PROJECTS here
No power switch required
Once you’ve programmed the Arduino with your choice of game, it’ll launch it straight away. High scores are saved in the Arduino’s small EEPROM memory, so they’re saved even when the power goes off. We’ve not bothered with a power switch, although you could integrate one into the build if you wish.Putting it together
You can put the Retro Gamebox into any container you want, so we’ve chosen a food container for its low cost and transparency. Full-size arcade games are impressive but we wanted you to see what’s going on inside and hopefully give you the idea that it’s not that complicated.Using a food container
We’ve used a 900mL food container from the local $2 shop and if you follow this route, you need to take care when drilling into plastic. First, set your drill speed to slow, otherwise you’ll tear the plastic to shreds. Second, don’t push too hard against the plastic to get the drill bit to bite, otherwise you’ll split the plastic. Don’t use cheap takeaway containers, but a sturdy microwaveable type. You could also use a Jaycar ‘jiffy box’, although we like the see-through look. The other thing we’d do differently next time is mount the RCA sockets towards the edge of the container where the plastic is a little stronger (it’ll handle connecting and removing cables much more easily).Mounting the components
We’ve used standard M4 machine screws on the joystick with washers on either side of the plastic lid (one under the bolt head, another before the nut). You can pick these up from any hardware store. We ended up using a tapered reamer to size the hole for the joystick rod. However, the fire button requires a sizeable 24mm hole for the centre shaft. If you don’t have a hole saw, the easiest way is to pick your centre point and measure 10mm out to eight points around in the circle. You then drill pilot holes at each point and expand them out using a 3mm drill bit. You then snip around the outer perimeter of the plastic joining those holes with a pair of side cutters (food container plastic is soft enough for this). After that, you’ll find you can just push out the centre piece, leaving a 24mm hole you can push the fire button shaft through.Place washers directly against the plastic so you don’t split it.
We raised the Arduino board off the bottom of the container using 5mm spacers (Jaycar) and 15mm M3 bolts (Bunnings), which fit into the Arduino’s four mounting holes. Don’t forget the washers on either side of the plastic before you add in those spacers. Using a see-through container makes it easy to mark out the mounting hole positions with a Sharpie before you drill. Finally, don’t forget the holes for the DC power socket and the USB port.
Wiring up the components
Our build method requires no direct soldering to the Arduino board. Instead, we used Dupont male wires, cutting off one end, soldering it into position and pushing the pin on the other end into the appropriate header hole on the Arduino board. The Arduino header sockets grab Dupont pins pretty well, so you shouldn’t have to worry about them falling out unless you start drop-kicking the Gamebox around. We also used a small amount of standard hook-up wire to connect the common ground on the joystick and the fire button LED to the fire button’s NO contact.You can use proper spade lugs to solder the joystick and fire button switches or solder direct as we did.
The Retro Gamebox’s circuit diagram is pretty simple.
Programming it & hooking it up
Although these classic games were originally ported to work on the Nootropic Design Hackvision board, we’ve designed the Gamebox so they’ll happily work here, too. Provided you’ve followed the circuit diagram when building your Gamebox, all you have to do is download the required files and libraries for each game onto your PC, compile the Arduino sketch and upload it to your Gamebox — no game code needs to be harmed in the making of this project.To make it easier, we’ve put each game together with a package of libraries your Arduino IDE will need in order to compile it. They’re based around Myles Metzler’s excellent Arduino TVout library, Nootropic Design’s controller library, which handles the joystick and fire button plus other libraries where appropriate.
For all games other than Space Invaders, just copy the contents of the ‘libraries’ folder across to your Arduino IDE’s \libraries folder and overwrite any existing files. With Space Invaders, you especially need to delete any existing TVout folder and replace it with the one bundled with the Space Invaders code. You then need to compile the sketch code and program your Arduino. The Space Invaders port was written for an older version of TVout and won’t work with the current release — that’s why you need to delete any previous version and use the specific version including the ZIP file.
We used the latest version 1.0.3 of the Arduino IDE available from arduino.cc/en/main/software.
Hooking it up to your TV
This is the fun bit. Use a standard stereo pair RCA cable and connect one side into the Retro Gamebox and the other end into the composite video and audio inputs of your TV or monitor. Go with a 3m or 5m cable to give you enough length that you’re not sitting on top of the telly to play. Powering the Gamebox, you’ll need a 9VDC or 12VDC power brick with the centre pin positive and the other ring negative. The Arduino pulls no more than 50mA, so just about any correct voltage/polarity power brick should work. You could also power the Gamebox with a USB power adapter from your smartphone or tablet and plug a USB cable into the Arduino — we’ve tested this and it works just fine.We’ve soldered the output resistors directly to the RCA sockets. It’s not ideal, but it’s quick.
PAL or NTSC?
By default, Gamebox is set to deliver US-based NTSC-standard video. That’s not a problem for modern TVs, as they all handle NTSC and Australia’s PAL video system, but if you’re planning to run this on an older CRT TV that’s PAL only, add a wire from D12 to ground to tell the Arduino you want PAL video output. Apparently, this also speeds up gameplay for some reason we haven’t figured out yet; most likely due to the change in video frame rate from 60Hz to 50Hz. Arduino only does monochrome video, so don’t expect to see flashy colours.Turn the TV volume down a bit before you start, as the Arduino’s audio output can be a maximum 5V peak to peak, and don’t forget to select the appropriate TV input to see the video.
To reset the Gamebox, just pull the power out and plug it back in again. You could add in a small pushbutton switch that pulls the RESET pin to ground, but that’s entirely optional.
For other interesting ARDUINO PROJECTS here
Writing your own games
Once you’ve had a play for a while, why not have a bash at writing your own games? If you’re thinking about gaming, a simple setup like the Retro Gamebox will help you understand what makes good gameplay without getting sidetracked with producing eye-popping graphics.Peer through the Arduino sketches for each game to glean ideas and head to the Nootropic Design web site for more details. Don’t forget the Arduino web site for more on coding the Arduino.
The classic Space Invaders still rocks!
Hackvision Arduino game sketches
You can find the original games available at nootropicdesign.com/hackvision/. To make it easier, we’ve put together each game as a separate ZIP pack, with all the required libraries included. You can grab them from the APC web site at apcmag.com/arduino.htm under Project 07. Note: Make sure you read through ‘Programming it & hooking it up’ section of this article for special information on uploading Space Invaders to your Retro Gamebox.if u like the post just say thank u in comment box.
No comments:
Post a Comment
its cool