motor control code