Controlling a motor based on voltage