Accelerometer and pulse width modulation