Step 1: Stop the Light: How to Play
This game is very easy to play and quite addictive. Your task is to stop a light which is traveling up and down the strip with the NES Zapper gun. Stop the light at the arrow, and you will advance to the next level. Each level increases the difficulty by speeding up the LED. The game will indicate missed shots by illuminating the moving LED red and pausing it for one second.
There are 3 levels in my code, green, yellow, and red. Each level speeds up the moving LED by 20%. If you are skilled enough to complete the red level, you are rewarded with a rainbow animation and the game resets back to level 1.
I've been wanting to make such a game after working with the LPD8806 based RGB strip project pack sold by Adafruit. Adafruit's project pack contains everything you need to power and run animations on the LED strip. Their project pack contains the strip, battery pack, cable and an Ardino clone they call the AtMega32U4 breakout board. Adafruit also has a great tutorial step you through the process of getting your strip up and running.
Along with the team at Adafruit.com, I'd like to give credit to Elmer Delooff
and his Green Flying Dot code which I used as the basis for my sketch.
Step 2: Stop the Light: Materials
The items needed to complete this instructable are pretty easy to find. You will need:
- Adafruit RGB digital belt kit http://www.adafruit.com/products/332
- NES system
- NES Zapper light gun
- A length of Cat 5 cable to extend the distance between the LPD8806 strip and the Ardunio
Lastly, I used a piece of foam core board to mount the strip and make a nice play area.
Step 3: Stop the Light: Build
The only thing I needed to modify from the Adafruit tutorial is that I spliced a piece of CAT5 cable between the ribbon cable and the LPD8806 strip. This allowed me place the LED strip a few feet away from the Arduino.
Once you have the belt kit working, you can load my code into your micro and start interfacing it to the NES.
Step 4: Stop the Light: the NES Zapper Gun
Looking at the switch in the gun I saw that it is a normally open device. I also noticed they put a peice of plastic on the trigger to make a hardware one-shot for the switch. I also found a hardware debounce of the gun circuit board. The hardware debounce allowed me to interface it directly with my Arduino.
Hardware debouncing is just what it sounds like, the gun contains a filter to ignore the bouncing of the first few milliseconds of the high/low switch transition. It basically helps our Arduino sense a proper grounded switch input. Its not perfect, but I find I can capture about 95% of the gun's trigger pulls.
Step 5: Stop the Light: Power the Game
At first, I was going to use the NES's power supply to power my Ardunio. But I figured it would probably be easier to run this thing off of batteries as I planned on using this at a school carnival. So I used the 6v pack from Adafruit's belt kit to power the game. What ever way you want to power this game, just make sure to tie the nintendo and Ardino's power and grounds together.
Step 6: Stop the Light: Mount the Strip
Once everything is connected, turn power on and if all goes well you should get a red light on your Arduino and the strip should turn blue and have a green dot running up and down its length.
Step 7: Stop the Light: Interface the Zapper Gun With the Arduino
Step 8: Stop the Light: Play the Game!
I operated this game for 4 hours at a elementary/middle school carnival and found that about 25% of the kids could complete the game within 7 shots. Some required more shots and some less. There was even a child in first grade who completed the game in 3 shots several times.
There is lots of room for improvement in the code. I'd really like to add a reset to the game to set it back to level 1 in the event a player can't complete the game. I'd also like to mount a vibrating motor from a cell phone in the gun and have the Arduino pulse it when it senses the trigger pull and give the player the sensation that he actually shot something. Drop me a line if you would like to see the details on how to add those features!