ECE434 Project - Water Gun Sentry Turret

Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder

Team members: Sophia Harrison and David Purdy

Grading Template

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

Add Extras

09 Executive Summary
09 Packaging
09 Installation Instructions 
09 User Instructions
09 Highlights
09 Theory of Operation
09 Work Breakdown
09 Future Work/Conclusions
09 Demo/Poster
00 Not Late

Score:  100/100

Executive Summary

Water Gun Sentry Turret

For our project, we created a water gun sentry turret. This project consists of several components including the BeagleBone AI-64 (BBAI64), a stepper motor and driver, a servo motor, a water pump, and a relay to fire the water pump. In addition, this project runs a Machine Learning program on the BeagleBone AI-64 to detect if a face is in view of the connected webcam and if the face's mouth is open. When the camera detects an open mouth, the centroid of the mouth is calculated and the servo adjusts the water gun's angle in order to shoot water into the mouth. The water shot is pumped from a water reservoir using the water pump which activates soon after the mouth is detected to be open.

What Worked:
What we got to work for our project was majority of the components we set out to implement. We successfully connected and video streamed a webcam with the BBAi64 and we were able to implement the servo motor, relay, water pump, and wifi to connect wirelessly. Our stepper motor was implemented but the rotations it produced were very small.

What Didn't Work:
We ran into some difficulty when trying to use the BBAI64 as it worked much differently compared to the BeagleBone Black used throughout the class. We were not able to use a lot of python packages and using gpios was different and it took us a minute to figure out how to do so. Additionally, for our project the stepper motor would only rotate very slightly and thus wasn't able to rotate the platform as much as we would like. One possible source to this issue we suspected was insufficient power to our stepper motor and driver.

In conclusion, we were able to create a water gun sentry turret which can detect when a person's mouth is open, aim the water nozzle, and gently shoot water into a persons mouth. While our stepper motor underperformed somewhat, the project still proved to be functional.


For our packaging we needed to use something that would protect the circuitry from water, since the components needed to work close to a water pump and nozzle. We chose a plastic container that could fit all of the peripherals and the BeagleBone inside it and also protect from possible water exposure. To allow for the power cords to be plugged into a wall, we drilled a small hole into the container towards the bottom on its side. Additionally, we had a square structure mounted on top of the plastic enclosure that held the servo motor, water nozzle end, and the camera on top of it secured with duct tape.

Here you can see images of the container and its contents:

Inside our project Stepper motor and servo motor connection Project Top View

Installation Instructions

For further instructions on how the code works and how to setup your environment, visit our github

Here are some instructions for how we set up the BeagleBone AI-64:

  • Install a graphical OS (makes it easier to debug later, We installed the Bullseye XFCE (with graphical desktop) for BeagleBone AI-64)
  • Once flashed on, to get the display port working you are going to want an ACTIVE micro display port adapter. Trust me there is a difference, the active ones have a thick block
  • Once you get this and boot you should see a desktop boot up on the display.
  • To get internet we setup the WIFI dongle and used this for downloading everything. We used instructions for setting up the WIFI drivers on the bone from the eLinux wiki page.

After setting up our BeagleBone AI64, we set up our various peripherals using the code found in the peripherals_test directory in our repository. Using those as a guide, you can set up the hardware and then run the main script and then the project should work!

Additional Hardware Needed:

User Instructions

Once everything is installed, to use the project all you have to do is ssh into the bone and run, the main python script. To stop the script you press q on your keyboard and that's it! These two steps allow you to start and run the project. See our gitrepo for the code and additional help.


To see our project in action, check out our demo on YouTube!

Theory of Operation

Our software is modular and there are contains several functions which handle different aspects of the project.

  • We first initialize the web cam and start reading the video stream
  • We use our machine learning script to detect when the camera sees an open mouth
  • We set up the PWM for the servo
  • We move the platform using the stepper motor a small increment every iteration of the loop, scanning for an open mouth
  • When an open mouth is detected we calculate the mouth's center and send the data to the servo angle calculation function
  • The angle needed to shoot the water into the mouth is calculated and sent to the servo
  • There are conditionals which decide if the mouth is within range and if the water gun should shoot
  • If the conditionals result in true, indicating the mouth is within range, the relay is sent a signal to fire up the water pump
  • The system waits 5 seconds for the water pump to finish shooting the water and then it goes back to the beginning of the loop, looking for an open mouth again

Work Breakdown

Here are the major tasks we completed for our project. We both sat down and worked on these together.

  • Setup BeagleBone AI-64
  • Get webcam to work and read its videostream using python
  • Get stepper motor to work with the BeagleBone and write python code to interface with it
  • Get servo to work, write python code to interface with it
  • Implement the relay, test with led first before adding water
  • Create housing for the project, drill holes into the enclosure
  • Setup remote ssh into bone so the script can be run remotely
  • Test system with water and tweak as needed

We were able to successfully complete all of these tasks.

Future Work

Some things we could do in the future with this project include making the main python script for the water gun run on the bone's startup, so that you do not have to ssh into it to get it started, making the project easier to use. Additionally, we would improve the wiring and circuitry for our stepper motor so that the platform can turn a wider range of angles so the field of view is not as limited.


In conclusion, our project is able to function correctly in aiming at a person's mouth and shooting water. As mentioned above, some improvements we could make involve using systemd to make the script start automatically as well as improving stepper motor performance. Futhermore, we accomplished all the tasks that we set for ourselves and our project successfully demonstrated what we wanted it to.

thumb‎ Embedded Linux Class by Mark A. Yoder