random direction L298 driver

If speed is controlled by a sensor, is it random?

I am familiar only with a cheap ultrasonic sonar module. It emits an 8-wave sound pulse when I toggle 1 pin HIGH then LOW. Another pin then goes from LOW to HIGH and drops back to LOW when the echo returns. I have to time the HIGH to LOW and turn that into distance. All those are digital, the analog is distance is calculated.

Where did you find a sonar that gives analog data directly? That would save code and cycles!