Wednesday, December 25, 2013

Gesture Based Controller


HC-SR04 Ultrasonic Ranging Detector
We would like to build a input device for our computer that allows the user to use hand gestures in order to command a computer program.  We begin by experimenting with a ultrasonic distance sensor in order to better understand its operating characteristics.  The ultrasonic sensor will form the basis for a measuring device that will be used to locate the user's hand in 3D space.  Most Arduino projects that require the use of an ultrasonic sensor will generally point you in the direction of Parallax's Ping Ultrasonic Sensor.  These sensors tend to be pricey (about $25 to $30) and so I searched for a cheap replacement.  In the end, I found a HC-SR04 Ranging Detector by SainSmart these are available for $2 to $5 at Amazon.com.  So way, way, cheaper, but the real question is how well do they work?  One point to note is that while the Ping sensor has three connections (Vcc, SIG, GND), the HC-SR04
requires four connections (Vcc, Trig, Echo, GND).  This requires just a slight modification of the example sketch for the Ping sensor from the Arduino IDE, viz. that separate pins are now to be used for the triggering and the reading of the sensor rather than using one pin that was switched between being used for OUTPUT versus INPUT.  Additionally, I abstracted the reading of a distance measurement by creating a function called getData(trigPin, echoPin) which facilitates easy reuse of the code for the reading of multiple sensors.  Distance measurements are returned in centimeters only.

Wiring Setup for HC-SR04
So, in order to get started, we build a simple sensor by connecting an Arduino Nano to a three ultrasonic sensors and run a simple sketch to log the sensor data by outputting it to the serial port.  We use three sensors so that we can test for the consistency and variations of each sensor thereby allowing us to determine the accuracy of the HC-SR04 ranging sensor.

More Soon...

No comments:

Post a Comment