In the above code, motor speed is controlled using PWM in the forward motion, then motor is braked, then motor speed is reversed and then again braking is applied. The code is written on the basis of working of L293D.