See Pulse Width Modulation PWM used to set the speed of a motor.
The PWM signal switches between two values, but the time at each value varies. More time at the high value, means its average value is higher and the motor turns faster.
See what the signal looks like as you command a faster/slower speed.
Also shown is the 'bridge' whose switches connect the PWM signal to the positive or negative ends of the motor, so setting its direction.
At the end of the PWM cycle, the voltage across the resistor is found - to measure the motor speed.
Press U and D to speed up or down, V to reverse motor, P for show PWM option, M for show Measurement option.