Raspberry Pi Turns Nerf Gun Into A Beastly Call Of Duty Weapon But Still Needs Work
It all starts with Fortnite -- or rather, a Fortnite-licensed Nerf
Sequeida uses a Raspberry Pi 4 as the brains of this operation. It has a 40-pin GPIO block that can accept the signal from each button. When the Pi registers a button press or the trigger being pulled, it sends a signal to the host computer via its onboard Wi-Fi using a Python script that Sequeida has published to GitHub. The host PC runs its own server script to receive data from the client, which is the Pi 4 in this case, and translates it to input for the game.
The last piece of the puzzle is movement. The Nerf gun doesn't have any sensors to send accelerometer data to the Raspberry Pi, but any old Android smartphone has the sensors and makes the data easy to read. Sequeida used an old Nexus 5 and wrote a small Android app with Google's Android Studio IDE to read accelerometer data and log it. The Pi 4 script uses logcat to read the accelerometer data and transmit that to the host PC as well. This movement then translates to mouse controls, so the player aims and turns based on the phone's accelerometer. This can -- and does -- result in the player pointing the gun away from the screen, but this is still a work in progress.
The last few minutes of the video are dedicated to a play test, which is really fun to see. He's able to turn, fire, move, and do just about anything else in the game. Unfortunately, the accelerometer data needs a little massaging, as in the video it's definitely quite jumpy and not really ready for competitive play. All the same, it's a really creative idea and it's executed pretty well. If you want to try it for yourself, head on over to Alfredo Sequeida's GitHub page and grab a copy of the code.