Experience the Windows Phone 7 Accelerometer using Wiimote


  image image

Let’s start at the beginning. What is an accelerometer? You can read about it in more detail here: http://en.wikipedia.org/wiki/Accelerometer, but effectively it’s a little doohickey that allows a device (in our case the Windows Phone) to detect the magnitude and direction of acceleration.

Windows Phone 7 (WP7) will have an accelerometer in it. The framework namespace that covers the accelerometer is Microsoft.Devices.Sensors. The class we care about here is the Accelerometer class. It has an important event called ReadingChanged. This event fires once you have started the accelerometer and one of the accelerometer values has changed. There are 3 important values, X, Y, and Z. Each represents the force of acceleration on that axis.

When I first started playing with the accelerometer I didn’t quite understand what the values for X, Y, and Z meant. When a device is sitting face up on a desk, X and Y will both be zero (or close to it). Z will be 1. Keep in mind that these values can be greater than zero for when greater than normal forces are put on them. Shaking for example.

As you can probably figure out, based on these values you can tell when a user tilts to the left, right, top, bottom, up or down.

Unfortunately there’s no easy way to test accelerometer code using the WP7 emulator. The one I like the most is using a Wiimote’s accelerometer. This was Bill Reis‘s idea.

For more goto Introduction to the Windows Phone 7 Accelerometer

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s