Old Zapper Gun Into T-Rex Game Controller OR Meet Quit Button and Many More

by narayandojo in Circuits > Raspberry Pi

2766 Views, 8 Favorites, 0 Comments

Old Zapper Gun Into T-Rex Game Controller OR Meet Quit Button and Many More

PSX_20210316_144551.jpg
Untitled design (1).png
Old Zapper Gun into T-Rex Game Controller || Raspberry Pi Pico

Hi, makers, in this instructables, 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.

Required Components and Software

PSX_20210316_152501.jpg
  • 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

Unscrew the Zapper Gun Using Screw Driver

20210315_180857.gif

After Unscrewing Open This Zapper Gun

20210315_182010.gif

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

Untitled design.png

Necessary Parts From the Zapper Gun

InkedUntitled design (3)_LI.jpg

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.

Now Take Out the Push Button From the Gun.

20210318_203010.gif

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

PSX_20210318_213416.jpg
PSX_20210318_213611.jpg
PSX_20210318_204422.jpg

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.

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

Capture2.PNG
PSX_20210318_214956.jpg
PSX_20210318_214053.jpg

Solder the Male to Female Jumper Wire to the Buzzer - LED Circuit

PSX_20210318_215131.jpg

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.

Microcontroller

PSX_20210318_215756.jpg
PSX_20210318_220821.jpg

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

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

Untitled design (7).png
PSX_20210319_161248.jpg
PSX_20210319_160638.jpg

·

  • 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)

IDE (Integrated Development Environment) for Programming the Pi Pico

Thonny.PNG
install1.PNG

Now we are using the Thonny Python IDE for giving the instructions to the pi pico, so that when we trigger the push button then desired action can perform

·

  • Download the Thonny Python IDE using this link
  • Install it in your machine

Install the CircuitPython Firmware Into Pi Pico

First Push & Hold the Bootsel Button and Now Plug.gif
  • Download the CircuitPython 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.

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

chrome_lQGQVmC9hS.png

Reboot Your Pi Pico for the Circuit Python

Gif.gif

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

Add the Adafruit Circuit Python Hid Library

Screenshot (453).png

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

Open the Thonny IDE. and Choose the CircuitPython Port

Screenshot (449).png

Code

Screenshot (452).png

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)

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

Run the Code by Clicking on Run Button at the Top

run the code.PNG

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

Testing || Zapeer Gun

After Testing, Unplug the Pi Pico From Your Computer

PSX_20210319_175331.jpg

Attach All of That Interfaced Hardware Inside the Gun and Screwed the Gun

Screwed the Zapper Gun

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

PSX_20210319_175553.jpg

Want to Perform Some Another Using the Gun

Capture.PNG
Old Zapper Gun into T-Rex Game Controller || Raspberry Pi Pico

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.