Save 24% on “active” status Pololu-brand products using code MEMORIALDAY24

Ghastly gas ghost

Posted by Jon on 9 October 2014

This project turns a innocent-looking ghost decoration into an ambush in wait for unsuspecting passersby. The basic idea is straightforward: whenever someone walks within a few feet of the ghost’s face, it blasts them with a terrifying burst of compressed gas.


Like Brandon’s and Grant’s props, this project features the Micro Maestro. The Maestro is a great controller because it can read analog and digital signals and use that information to trigger servo movement. The prop uses a single Sharp analog distance sensor to detect when something passes in front of it, at which point it activates a mini servo to briefly discharge a can of compressed air. The servo is linked by two lengths of solid-core wire through a servo arm to a hole I drilled in the spray-can trigger. The total length of the linkage can be changed by twisting and untwisting the two lengths of wire at the point that they meet in the middle of the cannister. For the linkage to work correctly, the servo needs to be mounted in just the right place and remain very rigid. At first I tried using wooden Popsicle sticks, hot glue, and duct tape to mount the servo to the spray-can, but the setup was too deformable and would stretch and bend instead of pull directly down on the spray-can trigger. So, I used a sumo blade, which is made of 0.036″-thick stainless steel, hot-glued the servo to it, and duct taped that to the spray-can. (Please note that we do not recommend hot-gluing directly to the spray-can.) The system uses a rechargeable 6V battery pack to power both the Maestro and the servo. For compressed gas, I used a generic keyboard spray-can duster, which is good for a few hundred blasts.

Here is the simple script that is running on the Maestro:

6000 1 servo # initializes servo position
1000 delay # waits 1 second for servo to reach position
0 1 servo # saves power by not sending pulses to servo

0 get_position 
250 greater_than if 
4000 1 servo # pull on compressed gas can trigger 
250 delay # wait 1/4" second
6000 1 servo # return to initial position
1000 delay 
0 1 servo # power saving 
30000 delay # wait 30 seconds before spraying again


This script assumes the Sharp distance sensor is connected to channel 0 and the servo is connected to channel 1.

It is recommended that you include a 10 μF cap or larger across power and ground somewhere close to the Sharp GP2Y0A02YK0F distance sensor. I found that adding such a capacitor really helped, reducing noise to the point where my prop’s range effectively doubled.

Complete parts list


While this prop isn’t quite as visually exciting as the ones we have made so far, it has elicited far more shrieks and laughs here around the office. It was hilarious to overhear our photographer shriek out loud several times as she accidentally set off the spray-can, and scared herself silly while she was arranging the system for photos. (She wants everyone to know that she hated working with this project.)

There are definitely other clever and fun variants and ways to startle people with similar servo-actuated projects. For example, the compressed gas can could be swapped for silly string, an air horn, or even some pneumatics. If you’ve made something that startles people with our products, feel free to #blowmeaway and share it in the comments below!

Disclaimer: We used a compressed gas spray-can used for dusting electronics in this project since we have them readily available around the office. The contents of these cans is not intended to be inhaled and can be flammable under certain circumstances. If you duplicate this project, be sure to read any warning labels and use products responsibly (such as by not aiming them directly at faces and using them in well-ventilated areas).


Post a comment

Using your Pololu account allows you to customize your avatar and manage your comments; you can also post anonymously.

Related Products

Micro Maestro 6-Channel USB Servo Controller (Assembled)
Sharp/Socle GP2Y0A02YK0F Analog Distance Sensor 20-150cm
3-Pin Female JST PH-Style Cable (30 cm) with Male Pins for 0.1" Housings
Power HD High-Speed Mini Servo HD-1705MG
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors