您要知道超聲波如何換算距離,因為不知道您的型號
我都列上給您
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0001)URM37V3.2%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0001)URM37V4.0%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0002)URM04V2.0%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0218)URM11V1.0%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0004)SRF01%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0005)SRF02%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0006)SRF05%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0007)SRF08%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0008)SRF10%E8%B6%85%E5%A3%B0%E6%B3%A2%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8
另外一般常見的HC-SR04系列則是
http://cf03.ickimg.com/bbsfiles/201704/f37be82150332904dd61ba1b1ea03602.pdf
然後您將計算距離的結果做小車控制馬達的依據,前進,後退,左轉,右轉
網路上也很多範例
https://wenku.baidu.com/view/add9dc59e518964bcf847c55.html
以上供參考
https://www.arduino.cn/forum.php?mod=viewthread&tid=4705&highlight=%E8%B6%85%E5%A3%B0%E6%B3%A2%E9%81%BF%E9%9A%9C
可以参考一下,百度上面有好多教程。