You would normally control the speed of a motor by writing an analogue value to an input on the H bridge but you seem to be only writing a digital value so that the motor will only be either on or off which fits in with the problem that you are seeing