Old Zapper Gun Into T-Rex Game Controller OR Meet Quit Button and Many More
by narayandojo in Circuits > Raspberry Pi
2809 Views, 8 Favorites, 0 Comments
Old Zapper Gun Into T-Rex Game Controller OR Meet Quit Button and Many More
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
- 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
After Unscrewing Open This Zapper Gun
After Open the Zapper Gun Now It Will Look Something Like This
Necessary Parts From the 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.
Now Take Out the Push Button From the Gun.
Solder the Three, Male to Female Jumper Wire to the Three Pins of the Push Button.
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
Solder the Male to Female Jumper Wire to the Buzzer - LED Circuit
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
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
·
- 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
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
- 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
Reboot Your Pi Pico for the Circuit Python
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
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
Code
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
Check That All Is Working Fine Before Placing the Hardware Inside the Gun
After Testing, Unplug the Pi Pico From Your Computer
Attach All of That Interfaced Hardware Inside the Gun and Screwed the Gun
Plug the Pi Pico to Your Computer & Enjoy Your Zapper Gun for Your Desired Action.
Want to Perform Some Another Using the 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.