Added code to calculate speed from the motor sensor