Ironically, a single smartphone has as many sensors as a human body needs. A GPS Sensor, Proximity Sensor, Com, Accelerometer and Gyrsocpe are the popular ones that are used in Smartphones.
Every single sensor has their purpose to help the smartphone to make them smart enough.
Here, in this article we will only explain the Accelerometer.
Background
An Accelerometer is a sensor device built in Windows Phone that measures the acceleration in three axes (X, Y, Z), relative to freefall. So, it is beneficial for a phone. Gaming is one of the major reasons to have this sensor in a phone.
So, we will have a small demonstration of an accelerometer.
Step 1: Start a new project that looks like:
Step 2: Add "Microsoft.Devices.Sensor" in your references. So, you can include it in your project namespace. Ensure you have "using Microsoft.Devices.Sensor;".
Step 3: Then create an object of an Accelerometer in your class.
Accelerometer acc = new Accelerometer();
//Suppose, I have 'acc'
Step 4: Now, create an Event that is raised when your Sensor becomes active. And you must code it inside the Constructor.
acc.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(acc_ReadingChanged);
acc.Start();
Step 5: Now, it’s time to handle the Handler, in other words acc_RedaingChanged.



Join the conversation! Your thoughts help the community grow.