Counting motor speeds from gravity sensor values