Distance sensing using ultrasonic sensor