Previously on windows 8 developers could access the accelerometer function on windows devices with  the library Windows.Devices.Sensors 


using Microsoft.Devices.Sensors;

With Windows 8.1  and Windows Phone 8.1  Microsoft.Devices.Sensors is replaced by Windows.Devices.Sensor whose methods are slightly different.
 
using Windows.Devices.Sensors;

With this code it will demonstrate about the Windows Phone App. But this method is universal among Windows 8.1 and Windows Phone 8.1 Apps

Lets Begin .....

1. Define the Accelerometer and initialize it for initialize use Accelerometer.GetDefault()method

public Accelerometer accelerometer { get; set; }
accelerometer = Accelerometer.GetDefault();

2. Cehck the accelometer is working or not and f it is avilable create Accelerometer readig capturing event

if (accelerometer != null)
               {
                   // Select a report interval that is both suitable for the purposes of the app and supported by the sensor.
                   // This value will be used later to activate the sensor.
                   uint minReportInterval = accelerometer.MinimumReportInterval;
                   desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16;
                   accelerometer.ReportInterval = desiredReportInterval;
                   //add event for accelerometer readings
                   accelerometer.ReadingChanged += new TypedEventHandler<Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);
               }
               else
               {
                   MessageDialog ms = new MessageDialog("No accelerometer Found");
                   ms.ShowAsync();
               }


developer can assign any value to desiredReportInterval. to archive highest efficiency here we using method to get the minimum interval between two accelerometer report feeds.

With UI , its having three text boxes that named as corX,corY and corZ  to show the results of accelerometer readings. with the accelerometer reading event you can get the readings as follow

/// <summary>
        /// reading accelerometer changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                AccelerometerReading reading = args.Reading;
                corX.Text = String.Format("{0,5:0.00}", reading.AccelerationX);
                corY.Text = String.Format("{0,5:0.00}", reading.AccelerationY);
                corZ.Text = String.Format("{0,5:0.00}", reading.AccelerationZ);
            });
        }


Here is Screen shot





Download code http://gallery.technet.microsoft.com/Accelerometer-81-e33eb93a