↑ Return to Projects

Senior Design Project: Super Spray

Visit the Official Blog
This is a brief summary of all of the work that I put into this senior design project. To re-live how Super Spray was created from the beginning with more detailed documentation and additional photos, be sure to visit the official blog at agjhdesign.wordpress.com.

Project Overview
As I mentioned in my bio, I majored in Computer Science and Engineering. CSE teaches the fundamentals of computer science and the application of engineering concepts with respect to both software and hardware. CSE students are required to complete the “Senior Design Project” to meet graduation requirements. Project requirements state that students must work in teams to design and build a project that takes advantage of hardware and software, while completing the project in roughly six months.

After much brainstorming and throwing out idea after idea, my partner and I decided on building what is now known as Super Spray. Super Spray is an interactive game in which the player is holding a custom built hardware peripheral – an embedded system.  This peripheral is a “water gun” that has been retrofitted with sensors and other components to make the game experience fun and unique.  The water gun itself has been stripped of its pressurized reservoir system in favor of a laser that indicates where the player is aiming.  The game is a piece of software written in C++ using OpenGL (graphics library) and OpenCV (image recognition library) running off of a regular desktop/laptop computer, and being displayed on a projector.  There is a webcam connected to the computer and pointing at the projector screen.

When a player aims at a target and pulls the trigger, a signal is sent wirelessly via bluetooth from the gun to the computer.  Upon receiving the signal, the computer will combine the OpenCV image recognition library with the input from the camera to “see” where the red laser is on the projector screen, and will check to see if a player has hit their target.  The player also interacts with a side mounted LCD screen on the gun that serves as a heads up display, showing the current score and the player’s ammo.  The player can even reload by pumping the water gun, a movement detected by accelerometers.  The gun is driven by an ATmega32 microcontroller, and written in C.

To get a better idea of how this entire system works, take a look at the diagram below.

Super Spray system overview.

Building the Gun
My responsibility was to retrofit the water gun with the sensors, solder the circuit, program the microcontroller to read the sensors properly and communicate with the computer and interface with the game software.

Below is the final hardware schematic that was designed and implemented.

Wiring diagram for Super Spray gun controller.

As documented in the schematic, a bluetooth modem, a 5mW laser, two three-axis accelerometers, an LCD display, and two 5v motors were all wired to an 8-bit ATmega32 microcontroller and placed inside the body of the gun. Here are some pictures of the actual process.

Here I am soldering the circuit for the gun.

The final wiring shot before putting the gun case together. All wires run to the microcontroller inside of the green sphere.

Holding the final product.

How it was Programmed
The microcontroller used in this project is an ATmega32 by Atmel. These microcontrollers can be programmed using Atmel’s own IDE “AVR Studio”, which is precisely what I did. I wrote code for each component one by one to ensure that everything was working correctly as a system along the way. The first step was to get the microcontroller to properly detect a trigger pull and debounce it appropriately. When the trigger is pulled, the motors should vibrate. Once a trigger pull was working, I worked on the LCD. I wrote a small API to make it easier to display the game information I wanted, such as the score and how much ammo was left. Now that the LCD was working, I used that to be able to test the accelerometers. I printed the acceleration value that the accelerometer was reading per axis to the screen, and figured out what would be an appropriate threshold to determine a reload. Two accelerometers had to be used for this project – one in the body of the gun and one in the pump handle. The microcontroller is constantly polling the accelerometers to see if the player is pumping the gun. If at any point the microcontroller detects that the difference between the two accelerometer values exceeds that threshold, a reload is triggered. The last and most important piece to program was the bluetooth. I wrote the bluetooth code to be integrated with the game software code seamlessly. All of the game information is stored in the software that is running the game, and then sent to the gun in real time. When the trigger is pulled, the bluetooth data is sent to the computer, informing it of that action. The computer will then check if it was a valid hit. If it was, it will increment the score, decrement the ammo and send those new values back to the gun for display on the LCD screen. Therefore, the gun is simply and efficiently pulling data from the game, and not duplicating any data of its own and storing it locally.

Demo Day
Below is a video of me commentating my project partner playing Super Spray at the senior design expo at UCI on March 11th 2011. I’ve also included a copy of the poster we had on display alongside of the game.

 

 

The poster we had on display for demo day that gives our project overview.