Can't make ultrasonic sensor work with motor controller
Pin numbers 0 and 1 are reserved for the Serial monitor which you're using on the board. 
The function int mdistance() should return an integer. 
You also didn't seem to set the motor pins as OUTPUT.