top of page

Old Zapper Gun Into T-Rex Game Controller

Updated: May 1, 2023


we are going to transform a old zapper gun, into a T-Rex Game controller or "Google Meet" quit button. Not this only but you can perform any other action by changing the shortcut-key. Now let’s see how to transform it.


Zapper Gun

Step 1: Required Components and Software



Zapper Gun
  • Old Zapper Gun

  • Raspberry Pi Pico with Soldered male Headers

  • Micro USB Cable

  • Male to Female Jumper Wire x5

  • 330 Ohm Resistor x1

  • LED x1

  • Buzzer x1

  • Screw Driver

  • Soldering Iron

  • Solder Wire

  • Thonny IDE


Step 2: Unscrew the Zapper Gun Using Screw Driver



Zapper Gun

Step 3: After Unscrewing Open This Zapper Gun


Zapper Gun

Step 4: After Open the Zapper Gun Now It Will Look Something Like This


Zapper Gun

Step 5: Necessary Parts From the Zapper Gun



Zapper Gun


From this Zapper Gun, here we need only the trigger push button, trigger clip with the zapper gun case. For more clarification you can refer to the above images.


Step 6: Now Take Out the Push Button From the Gun.



Zapper Gun

Step 7: Solder the Three, Male to Female Jumper Wire to the Three Pins of the Push Button.



Zapper Gun

Zapper Gun





Zapper Gun



























Here we are soldering the female wires so that in the further steps we can connect them to the

male header of the pi pico.


Step 8: Now Solder the Buzzer, Led and Resistor With Each Other See the Below Images for the Circuit Diagram



Zapper Gun

Zapper Gun

Step 9: Solder the Male to Female Jumper Wire to the Buzzer - LED Circuit






Zapper Gun

Now solder the one male to female jumper wire to the common anode pin of the buzzer and led and another male to female jumper wire to the common cathode pin of the buzzer and led.


Step 10: Microcontroller


Zapper Gun

Zapper Gun

For Controlling the T-Rex Game OR performing any other action, here we are using the Pi Pico Microcontroller with the Soldered male Headers


Step 11: Interfaced the Buzzer, Led and Trigger Push Button to the Pi Pico



Zapper Gun

Zapper Gun

Zapper Gun

  • Long leg of LED & Buzzer → GP15 (Pico)

  • Short Leg of Led & Buzzer→ GND (Pico)

  • Brown Wire Pin of trigger push button → GND (Pico)

  • Yellow Wire Pin of trigger push button →GP27 (Pico)

  • Red Wire Pin of trigger push button → VBUS (Pico)


Step 12: IDE (Integrated Development Environment) for Programming the Pi Pico



Zapper Gun

Step 13: Install the Circuit Python Firmware Into Pi Pico




  • Download the Circuit Python UF2 file using this link

  • Push and hold the BOOTSEL button and plug your Pico into the USB port of your computer. Release the BOOTSEL button after your Pico is connected.


Step 14: Pi Pico Will Mount As a Mass Storage Device Called RPI-RP2 in Your Computer



Zapper Gun

Step 15: Reboot Your Pi Pico for the Circuit Python




Drag and drop the Circuit Python UF2 file onto the RPI-RP2 volume. Your Pico will reboot. You are now running Circuit Python.


Step 16: Add the Adafruit Circuit Python Hid Library


Zapper Gun


add the adafruit circuitpython_hid library for adding the keyboard and mouse capabilities in to the pi pico.

  • Download the library by clicking this link

  • Paste this lib folder into the Pi Pico Volume

Step 17: Open the Thonny IDE. and Choose the Circuit Python Port



Zapper Gun

Step 18: Code


Zapper Gun

Write the below code and save the file with the name of code.py. (If you are saving the file with some another name then in that condition you will have to upload the code each time when you plugged the pi pico.)

###################################################################################

import time

import usb_hid

import board

from digitalio import DigitalInOut, Direction, Pull

from adafruit_hid.keyboard import Keyboard

from adafruit_hid.keycode import Keycode

keyboard=Keyboard(usb_hid.devices)

btn1_Pin = board.GP27

led1_pin = board.GP15

btn1 = DigitalInOut(btn1_Pin)

btn1.direction = Direction.INPUT

btn1.pull = Pull.UP

led1 = DigitalInOut(led1_pin)

led1.direction = Direction.OUTPUT

while True:

if btn1.value:

led1.value = True

keyboard.press(0x2C)

else:

led1.value = False

keyboard.release(0x2C)

#######################################################################################


Step 19: Run the Code by Clicking on Run Button at the Top



Zapper Gun

Step 20: Check That All Is Working Fine Before Placing the Hardware Inside the Gun




Step 21: After Testing, Unplug the Pi Pico From Your Computer



Zapper Gun

Step 22: Attach All of That Interfaced Hardware Inside the Gun and Screwed the Gun




Step 23: Plug the Pi Pico to Your Computer & Enjoy Your Zapper Gun for Your Desired Action.



Zapper Gun

Step 24: Want to Perform Some Another Using the Gun





Zapper Gun

If you want to perform some another action using the same gun then in the line no. 18 & 21 just change the shortcut key according to your desired action & run the code again that’s it.


Click on this link to see the key code of any keyboard key.


Thank You. If you have any question regarding anything don’t hesitate to ask. And don’t forget to share your work also.

28 views0 comments

Comments


bottom of page