RP2040 Nintendo Light Zapper

by alekthegenius in Circuits > Raspberry Pi

370 Views, 3 Favorites, 0 Comments

RP2040 Nintendo Light Zapper

Lightzapper.png

Hi, today I will walk you through how I designed an NES light zapper that uses an RP2040, which retrieves the data from a gyroscope and then sends mouse movements to the computer. I am homeschooled but currently attending the Classical Conversations Challenge B homeschool program in 8th grade.

All of the code and design files are available in this GitHub Repository.

I will walk you through how I derived my Light Zapper and how you can build your own!

Supplies

History

Even though I'm growing up in a time when NES consoles are old school, I respect the crazy innovations companies like Nintendo, Microsoft, IBM, Apple, etc., achieved back in the early days of computers.


The original NES Light Zapper used a simple light detector that would detect if the part of the screen it aimed at was black or white, which is why, when pulling the trigger, for a split instance, the CRT display would show a black screen with white boxes around the birds. If the Light Zapper saw white, then bam, a duck was down, but if it saw black, then you would be met with a sniggering dog. Because this all happened in a fraction of a second, it required precise timing to pull it off, which is why it won't work for modern TVs because the refresh rate of LED displays is different than old CRT screens. Knowing this, people have been able to change the timing and get the Nintendo Light Zapper working on modern-day screens. However, that's good and all, but you need a NES to pull it off, which is where my project comes in. My Light Zapper uses an MPU6050 gyroscope board to send the data of the device's rotation to the RP2040, translating the data into mouse movements for the computer. This means that you can use this for any device that supports USB! I haven't gotten a chance to print it yet, but I have tested the code on a hacked Nerf Gun and have gotten it to work

Design

Nintendo-Entertainment-System-NES-Zapper-Orange-L.jpg
Light_Zapper_2023-Apr-10_12-38-38PM-000_CustomizedView32366384083.png
Screenshot 2023-04-09 184253.png
Screenshot 2023-04-09 184303.png
Screenshot 2023-04-09 184330.png

I will now go into detail about how I designed the Light Zapper. I will break it into two sections: the body and the trigger. If I had more experience using meshes, I probably could have come up with something more intricate. Even still, I believe the final product accurately reflects the look of a Nintendo Light Zapper and should be fantastic for 3d printing.


At the time of writing, the Autodesk Gallery is temporarily unavailable, so to view the design use this link: https://a360.co/3UoEt4W. I also have the Fusion 360 design file attached below.


To attach the circuit boards to the light zapper, I recommend just using hot glue.


Figure 1 shows an image of the original light zapper to compare it with my design. MLA citation:

"NES Zapper." Wikipedia, Wikimedia Foundation, 4 Apr. 2023, en.wikipedia.org/wiki/NES_Zapper. Accessed 9 Apr. 2023.

The Body

Screenshot 2023-04-09 183444.png
Screenshot 2023-04-09 183502.png
Screenshot 2023-04-09 183515.png
Screenshot 2023-04-09 183536.png
Screenshot 2023-04-09 183638.png
Screenshot 2023-04-09 183654.png
Screenshot 2023-04-09 183730.png
Screenshot 2023-04-09 183826.png
Screenshot 2023-04-09 183849.png
Screenshot 2023-04-09 183914.png
Screenshot 2023-04-09 192002.png

I tried many different methods of creating the body but settled on extruding the central handle part, then extruding a cylinder. Because I do not currently possess a Light Zapper, I utilized a Nerf gun I had lying around to create the measurements for the handle to provide a comfortable fit in hand.


  • I first created a rough sketch of the handle of the Nintendo Light Zapper.
  • I then sketched a circle on the handle and extruded it for the barrel of the zapper.
  • I then blended the cylinder better by extruding a square into the barrel. I also added a ridge down the bottom of the barrel to stick with the theme of the Nintendo Light Zapper.
  • Because I feel there can never be too much fillet, I added fillet to round the rough corners.
  • I then cut 2mm holes to keep everything together once I split it in half.
  • To mimic the design of the Light Zapper, I added a top and bottom wrapper.
  • Until then, I have been using the default steel material, so I changed it to ABS and the main body to orange.
  • Lastly, I split the main body in half. I then hollowed it out to make room for the electronics and trigger.
  • Later on, I added a hole in the bottom for a USB-C cable to go through.
  • Then to finish it off, I filleted everything because why not?

Trigger

Screenshot 2023-04-09 183939.png
Screenshot 2023-04-09 183954.png
Screenshot 2023-04-09 194221.png
Screenshot 2023-04-09 184019.png
Screenshot 2023-04-09 184027.png
Screenshot 2023-04-09 184037.png
Screenshot 2023-04-09 184057.png
Screenshot 2023-04-09 184146.png
Screenshot 2023-04-09 184159.png
Screenshot 2023-04-10 085707.png

The trigger was by far the trickiest part, but hopefully shouldn't be too complex to 3d print and should have a smooth pull action.


  • Firstly, I cut a rectangular hole into the handle and wrappers.
  • I then outlined the trigger, again using the Nerf Gun for the measurements, then extruded.
  • I then filleted everything again.
  • After that, I made guide rails for the trigger to slide on.
  • I then created holes for the wires to pass through.
  • I also added a hole in the trigger for the spring to go into.
  • I cut the guides in half, allowing a USB-C cable and a push button to squeeze through.
  • Realizing that nothing prevented the trigger from falling out, I extruded four boxes to keep it in.
  • I also added a part to push on the tactile button.
  • I applied fillet to everything to make everything look clean.
  • To finish it off, I added most of the main circuit boards to give an idea of the layout of everything.

Code

codye.png

The MPU6050 is hooked up at GP1 and GP2, the push button to GP2, and the buzzer to GP3.

First, you must install Circuit Python onto the Seed Studio RP2040 Microcontroller, then install the Adafruit_HID and Adafruit_MPU6050 Libraries.

Here is the code for the Seed Studio RP2040 Microcontroller:


import time
import board
import adafruit_mpu6050
import busio
import usb_hid
from adafruit_hid.mouse import Mouse
from digitalio import DigitalInOut, Direction, Pull
import simpleio




m = Mouse(usb_hid.devices)
i2c = busio.I2C(board.GP1, board.GP0) # uses board.SCL and board.SDA
mpu = adafruit_mpu6050.MPU6050(i2c)


btn = DigitalInOut(board.GP2)
btn.direction = Direction.INPUT
btn.pull = Pull.UP


simpleio.tone(board.GP3, 1000, duration=2.0)
time.sleep(2)


m.move(x=-1920, y=1080)


while True:
#print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2"%(mpu.acceleration))
#print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s"%(mpu.gyro))
#print("Temperature: %.2f C"%mpu.temperature)
#print("")
#print(btn.value)
y = int((mpu.gyro[2])*45) + 0
x = int((mpu.gyro[1])*45) + 1

#print("Y: {}".format(y))
#print("X: {}".format(x))
if (x >=2 or x <= -2) and (y >=2 or y <= -2):
m.move(x=x, y=-y)

if btn.value == False:
m.click(Mouse.LEFT_BUTTON)
simpleio.tone(board.GP3, 5000, duration=.25)

We first import the desired libraries, then set the gyroscope, buzzer, and button variables. Secondly, we play the calibration buzz, telling you to aim the zapper in the bottom left corner. Finally, the while loop extracts the data from the gyroscope and then sends mouse coordinates to the computer. It also presses the left mouse button when the trigger is fired.

Conclusion

And there you have it, a Light Zapper that works with any computer. Now you can bust out your firing accuracy with Duck Hunt or practice drawing in Wild Gunman. Thank you for reading. Until next time!