according to the PWM signal available at its base. Higher the duty cycle the average voltage across motor will be high which results in higher motor speed and vice versa. Change of DC motor direction is attained using the DPDT switch S1 which on application just toggles the polarity applied to the motor.