With a bit of ingenuity, this maker repurposed an old game console IR gun to make a fun Raspberry Pi Pico-powered HID controller.
It never ceased to amaze us what projects makers create by repurposing old hardware. In this example, a curious maker wanted to test out the new Raspberry Pi Pico. And, what better way than hacking into an old game console Zapper gun to make a T-Rex Chrome game controller. We soon learn it can do much more. We caught up with Ankit to get the details.
Thank you for submitting your project via our website, Ankit. Please tell our readers a little about yourself and what got you interested in electronics.
Hi, my name is Ankit Birla. I have completed my graduation in the Internet of Things & currently, and now I’m pursuing the PG Diploma in Big Data Logistic & Operation Research.
In electronics, I'm passionate to make things that can solve real/daily life problems in a simple, smart, fun & frugal way. Besides this, I am also interested to create STEM activities, products, and development boards through which not only kids but also anyone can understand the basic concepts, and interact with the tech in an easy way.
Being frugal is a great trait for a maker. Repurposing or making projects using recycled parts can be very rewarding. Tell us about the Narayandojo.
It is a STEM Club or a virtual place to do STEM, DIY activities, or anything which takes the creativity or confidence within you. So, in the Narayandojo we make the educational kit, held tiny courses, organize STEM based webinars, and DIY concepts. We try to do each thing in a fun way or from basics so that anybody can learn by doing.
Sharing knowledge is also a great maker trait. What was the inspiration for making your project?
When the $4 Pico microcontroller was launched by Raspberry Pi, we were excited to make something with this new low-cost microcontroller. Around the same time, we noticed that Adafruit released firmware for the Pi Pico with the support of HID (Human Interface Device) library.
During my semester break, I found my old video game with the zapper gun and decided to convert that zapper gun into a keyboard key controller with the use of Pi Pico, knowing that it has the HID capability. We thought of ways to use the zapper gun as a keyboard key or keyboard shortcut key to perform different keyboard or mouse actions. These included, making the Dino jump in the Chrome Dino game, controlling Google Meet or Zoom meetings, and controlling a presentation slide.
That sounds like fun. Can you give us a broad overview of how it works and the parts you used?
The Zapper gun's trigger button (Push Button) is connected to the digital pin of the Pi Pico. The LED and buzzer are connected to another digital pin. When we trigger the zapper gun (or when the push button reads a high signal), the gun performs the same keyboard key/shortcut key action, which we have pre-loaded in the program. A buzzer sounds and an LED starts blinking on the gun when it performs the action.
The parts we used included the old zapper gun, Raspberry Pi Pico with soldered header, Micro USB Cable, five male to female jumper wires, an LED with 330 Ohm resistor, and a buzzer.
We used a screwdriver, soldering iron and solder to put it together, and we used Thonny IDE software to program the Pico.
For the code, we used CircuitPython because it is an easy-to-use python-based programming language, and in this project, Pi Pico supports the circuit python with the HID capability.
Was the coding written from scratch or repurposed from a different source?
The coding is from scratch by taking the instruction from the official Raspberry Pi Pico guide.
from digitalio import DigitalInOut, Direction, Pull
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
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
led1.value = True
led1.value = False
That makes it easy. What challenges did you need to overcome with the build?
Two things. Firstly, setting up the whole circuit inside the gun case. We needed all of the hardware and wiring done within the confined space. We used double sided tape to hold the components in place.
Secondly, a little fear to starting with the new board. This is a genuine challenge for a new nerd like me, but to overcome this, I just followed the "Official Raspberry Pi Pico Guide".
You mentioned it being able to work with the Chrome Dino game and to control a Google meeting. What other applications could it be used for and how would someone go about doing that?
Any action that can be performed with a keyboard key, or a combination of keyboard key and mouse. This could include changing slides in a PowerPoint presentation, for launching browser, etc.
If you want to perform another action using the same gun, update the keyboard.press(xxxx) and keyboard.release(xxxx) code on line numbers 18 and 21. Once they are updated to the shortcut key that matches your desired action, simply run the code again, that’s it.
A list of the shortcut keycodes can be found here: https://github.com/adafruit/Adafruit_CircuitPython_HID/blob/main/adafruit_hid/keycode.py
Too easy. And, if any or our readers want to make one for themselves, where can they get the wiring diagram and code files?
We will provide the files for you to post on your website and in this article. This includes build instructions.
The Build: Zapper Gun
Full build details written by Ankit can be found on our website as a PDF download or on the Instructables: https://www.instructables.com/Old-Zapper-Gun-Into-T-Rex-Game-Controller-OR-Meet-/