First and foremost, if you want in depth information about the accelerometer you should check out Dave Edson’s excellent blog post, Using the Accelerometer on Windows Phone 7. While his post is extremely informative, it was a bit of overkill for what I needed. I assume this may be true for a lot of you as well.

I just needed to recognize a simple gesture I wanted to see what it “looked” like to the accelerometer. I didn’t smooth out the curve or use the AccelerometerHelper class. Here are the steps I followed to determine that the raw data appeared to be sufficient for my needs:

Start the accelerometer and record the data Perform the gesture Stop the accelerometer Use Excel to analyze the data Write the gesture detection code Test, Test, Test

I wrote a quick and dirty program (included below) to capture the data and send me an email. The email is plain text that I save into notepad then import into Excel as a delimited text file.

These are the x-axis readings for one trial for me flicking the phone with my right hand:

There are two key points on this chart: When the x value hits about 1.3G, and when it hits about –2G. My gesture detection code looks for these values, in this order, in a small time frame (about 1 second).

Tips

Perform several trials before you start coding your gesture recognition. If possible, use different people. What worked 10 out of 10 times for me worked 3 out of 10 times for someone else.

Left and Right handed gestures can be drastically different.

Be cognizant of how long the gesture should take and code your recognition accordingly.

Relax your gesture parameters as much as possible, but be wary of false positives. In order to prevent stacking gestures, I put in a pause of about 250 ms between gestures.

Give some sort of feedback when they successfully perform a gesture. A vibration lasting about 200 ms seemed to work well for my scenario.

Download Accelerometer Test Solution Here