PWM sets the speed. The direction pin sets the polarity of the motor output and is usually connected to a digital output.