Must Read

Payday Loan Debt Consolidation – Offering Immediate Debt Relief

Payday loan debt consolidation is an efficient process to help you repay your high interest loans with great ease....

Black Friday Payday Loans – Get the Cash You Need Immediately to Take Advantage of Retail Sales Now!

Black Friday is one of the most exciting days of the year for shopping. Retail sales explode as shoppers...

Bad Credit Home Loan Refinance Mortgage Online

Just because you have bad credit doesn't mean you can't get a refinance home loan. In fact, it has...

Exactly About First Time Home Buyers Grants: An Even Better Option To Having A Home

The US government and many private organizations are already offering financial assistance for housing through first time home buyers...

The Cost of Refinancing a Home – Is It Worth It?

There's an old adage that says you shouldn't refinance a home unless you can lower your interest rate by...

Why you should start business blogging?

If you just start your own business, then you might want to diversify your advertising methods. This allows you...

All Windows Phone 7 physical devices include an accelerometer that measures acceleration forces due to gravity, or due to forces caused by moving the device, and indicates the orientation of the device. The Accelerometer API in the operating system of the device can be accessed by Microsoft® Silverlight® for Windows Phone and XNA® for Windows Phone applications.

To use the Accelerometer API, you must do the following:

  • Add a reference to the assembly Microsoft.Devices.Sensors to your project.
  • Instantiate an accelerometer.
  • Specify a callback in the form of an event handler or lambda expression that will receive the data.
  • Start the accelerometer.

The following code example shows how to use the Accelerometer API.

var accel = new Accelerometer();
accel.ReadingChanged += new EventHandler
// Error starting the accelerometer.

You can then access the readings as they change in your event handler. Remember that the event handler runs on a different thread from the user interface (UI), so you must invoke a method on the UI thread if you want to update the UI with the discovered values.

void Accelerometer_ReadingChanged(object sender,
AccelerometerReadingEventArgs e)
string xCoordinate = e.X.ToString(“0.00”);
// Acceleration in the X direction.
string yCoordinate = e.Y.ToString(“0.00”);
// Acceleration in the Y direction.
string zCoordinate = e.Z.ToString(“0.00”);
// Vertical acceleration.
DateTimeOffset time = e.Timestamp;
// When this reading was obtained.

The values returned are of type Double and indicate the force applied in the three planes of the device. When it is laid flat on its back, they will return values very close to X=0, Y=0, Z=-1. When held vertically, they return approximately X=0, Y=-1, Z=0. Figure 1 illustrates how the values indicate the orientation of forces on the device.

The orientation of forces detected by the accelerometer

The accelerometer also exposes the State property, which returns a value from the SensorState enumeration indicating the current state of the accelerometer. Typical values are Initializing, Ready, NoData, NoPermissions, Disabled, and NotSupported.

To stop the accelerometer when you no longer require it, which signifi cantly reduces the processing load on the device, call the Stop method.

For more information, see “Accelerometer for Windows Phone” on MSDN ( aspx). You can also download a code sample that demonstrates using the Accelerometer API from “Code Samples for Windows Phone” on MSDN (


Previous articleScenarios for Device Capabilities
Next articleCamera


Please enter your comment!
Please enter your name here

Latest News

Digital Marketing for Beginners

Digital marketing for starter, Let to basic learning about connecting with your audience in the right place...

What are 7 things poor people do that the rich don’t?

1. poor people watch TV in which people read books how many hours you spend in front of the TV and when...

Top 18 best small business ideas for beginners starting

A small business can be frightening and requires plenty of careful planning there are many small business ideas which can be beneficial...

Summer that makes you happy

We saw were already here I've been thinking about some of the things. I used to do with my husband even though...

4 Point to helpful tips specifically for caregivers

What you need to take a vacation. I know it sounds impossible creative and try to make it work for you almost...

More Articles Like This