Showing posts with label controller. Show all posts
Showing posts with label controller. Show all posts

Tuesday, April 20, 2010

Hacking the Toy Gun

Today we started taking apart one of the toy guns that will eventually become the wireless controller for the NES.

Toy gun that will soon become a wireless NES controller

The toy gun is really 4 plastic parts that are held together by many screws.  Two of the parts are actually glued together at the ring of the front of the flashlight, which is located below the barrel of the toy gun.  To disassemble the gun, we unscrewed all of the screws and used a saw to cut off the glued-on ring of the flashlight.


Inside of toy gun after flashlight ring was cut off with saw

Once the ring was removed, we had easy access to all four pieces of the toy gun as well as the underlying circuit that powers the speaker and flashlight.  The gun is actually perfect for this project because it provides an easy-access panel to the battery compartment, which we can gut out and replace with the Firefly node.  This will allow for easy programming of the node while it is embedded in the toy gun.

Using a Dremel to round off the edges where we cut off the flashlight ring

Lastly, in an effort to improve the aesthetics of the gun were we had sawed off the flashlight ring, we used a Dremel to round off the edges.  During the next week, we'll embed the Firefly node in the toy gun and program it to wirelessly transmit accelerometer data to the receiver node connected to the NES.

Hardcore Hackers

Wednesday, April 7, 2010

Interfacing the NES Controller with the Firefly Microcontroller

Today we successfully interfaced the NES controller with the Firefly microcontroller.

Following the instructions here and here, we programmed three GPIO (General Purpose Input/Output) pins on the Firefly to mimic the NES in retrieving the states of the buttons.

An NES controller contains seven wires. Two of the wires quite literally do nothing. They're not even connected to the 4021 serial IC in the controller. The other five wires are +5 V, Ground, Latch, Pulse, and Data. The NES performs the following operations in order to read the button states from the controller:

  1. Every 16.667 milliseconds (60 Hz), the NES sets the Latch line high for 12 us and then low again.
  2. Six us later, the NES sends out eight 12 us period pulses on the pulse line.
  3. The NES controller sends out the states of the buttons for each pulse in the following order: A, B, Select, Start, Up, Down, Left Right.
It's that simple. Check out the diagram below for a more visual explanation.
The majority of the GPIO pins on the Firefly are hidden under the mini-SD card slot, so eventually we'll probably have to de-solder the mini-SD card slot to access them.



In the mean time, we used the Firefly programmer/debugger board which provides additional access to the GPIO pins. For this experiment, we used NRK_DEBUG_0, NRK_DEBUG_1, and NRK_DEBUG_2. Note the "NRK_" prefix. We omitted that prefix initially, which prevented our program from working for several hours.

NES Controller plug connected to breadboard

Firefly programmer/debugger (left) connected to Firefly node (right)

Firefly node in action

Finally, we'll leave you with a video of our program that prints out to the serial terminal what buttons are being pressed on the NES controller. The next step of the project will be to interface the Firefly directly with the NES game console so that we can play the NES using the keyboard of the computer.

Introductions!

Hello interested readers! This is a blog for the design and implementation of a Wireless Rifle Controller for the Nintendo Entertainment System, specifically for the NES video game "Cabal." This project is being completed for the Spring 2010 ESE 350 (Microcontrollers) class at the University of Pennsylvania.

So what exactly are we doing? Our idea is to create an alternative user interface for a classic Nintendo game: Cabal. We would like to provide the users with a more natural interface instead of the classic Nintendo controller (Directional pad, A, B, Start, Select).

We plan to take a stock toy gun and mount a microcontroller on or inside of it. This will allow the user to physically strafe in front of the display to strafe the character on screen, providing a more in-depth gaming experience. Right now our intention is to use the Firefly microcontroller to achieve this, most likely one on each gun and a receiver node at the NES controller input as well.


An added benefit of using this input device would be that it is wireless, allowing the user freedom of movement when playing. A possible “reach” function would be to add a small vibrating motor to give force feedback to the user when shooting.

Check out our proposal presentation slides here.

We'll post periodically with updates about the project. In the mean time, check out this video of Cabal in action: