Another option for controlling the direction and speed of a motor with the PWM is to use a continuous rotation servo demonstrates a different approach of using PWM.
A continuous rotation servo is a standard servo modified in 2 ways. First the position feedback"position feedback" in the servo is disconnected and set to always read as if the servo was in the center position. Second the stop that"stop" which physically prevents the motor from turning 360 degrees is removed.
Then if you sendset the servo to 0 degrees it rotates fast in one direction if you set it 180 degrees it move in the otheropposite direction.
More information: