{"id":10020444,"date":"2024-12-06T21:38:54","date_gmt":"2024-12-06T13:38:54","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020444"},"modified":"2024-12-06T21:38:54","modified_gmt":"2024-12-06T13:38:54","slug":"%e6%89%8b%e6%8a%8a%e6%89%8b%e6%95%99%e4%bd%a0%e7%8e%a9%e8%bd%ac%e8%b6%85%e5%a3%b0%e6%b3%a2%e4%bc%a0%e6%84%9f%e5%99%a8%ef%bc%88%e5%8e%9f%e7%90%86%e9%a9%b1%e5%8a%a8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020444","title":{"rendered":"\u624b\u628a\u624b\u6559\u4f60\u73a9\u8f6c\u8d85\u58f0\u6ce2\u4f20\u611f\u5668\uff08\u539f\u7406+\u9a71\u52a8\uff09"},"content":{"rendered":"<p>\u6211\u4eec\u90fd\u77e5\u9053\u58f0\u97f3\u662f\u7531\u7269\u4f53\u632f\u52a8\u4ea7\u751f\u7684\uff0c\u4eba\u80fd\u542c\u5230\u7684\u9891\u7387\u572820Hz~20kHz\u3002\u9891\u7387\u5c0f\u4e8e20Hz\u7684\u53eb\u6b21\u58f0\u6ce2\uff0c\u9891\u7387\u5927\u4e8e20kHz\u7684\u53eb\u8d85\u58f0\u6ce2\u3002<\/p>\n<p>\u8d85\u58f0\u6ce2\u53ef\u4ee5\u5728\u7a7a\u6c14\u3001\u6db2\u4f53\u548c\u56fa\u4f53\u4e2d\u4f20\u64ad\uff0c\u53ef\u4ee5\u88ab\u7269\u4f53\u53cd\u5c04\u3001\u6298\u5c04\u3001\u6563\u5c04\u7b49\uff0c\u5e76\u4e14\u6709\u9891\u7387\u9ad8\u3001\u6ce2\u957f\u77ed\u3001\u7ed5\u5c04\u73b0\u8c61\u5c0f\u3001\u65b9\u5411\u6027\u597d\u7b49\u7279\u70b9\u3002\u4ece\u800c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7528\u9014\uff0c\u533b\u5b66\u5f71\u50cf\u3001\u6e05\u6d01\u7269\u54c1\u3001\u6750\u6599\u68c0\u6d4b\u3001\u975e\u63a5\u89e6\u6d4b\u8ddd\u7b49\u7b49\u3002<\/p>\n<p>\u672c\u6b21\u6211\u4eec\u8981\u8bb2\u7684\u8d85\u58f0\u6ce2\u4f20\u611f\u5668\u5c31\u662f\u975e\u63a5\u89e6\u6d4b\u8ddd\uff0c\u7528\u4e8e\u6d4b\u91cf\u7269\u4f53\u4e0e\u4f20\u611f\u5668\u4e4b\u95f4\u7684\u8ddd\u79bb\uff0c\u53ef\u7528\u4e8e\u8f66\u8f86\u5b89\u5168\uff08\u5012\u8f66\u96f7\u8fbe\uff09\uff0c\u5b89\u9632\u7cfb\u7edf\uff08\u68c0\u6d4b\u5230\u79fb\u52a8\u7269\u4f53\u5e76\u89e6\u53d1\u8b66\u62a5\uff09\uff0c\u5de5\u4e1a\u81ea\u52a8\u5316\uff08\u7269\u4f53\u5b9a\u4f4d\u3001\u68c0\u6d4b\u548c\u907f\u969c\uff09\u7b49\u7b49\u3002<\/p>\n<h2>1. \u6e90\u7801\u4e0b\u8f7d\u53ca\u524d\u7f6e\u9605\u8bfb<\/h2>\n<p>\u672c\u6587\u9996\u53d1 <strong>\u826f\u8bb8\u5d4c\u5165\u5f0f\u7f51<\/strong> \uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=b%2BTWbw4t%2BzVAmtflYOdmOA%3D%3D.agFJAan%2FeF2kHMfYpV5al13IjaW5f6jG5UZaCI4E%2Bnc%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/<\/a> \uff0c\u6b22\u8fce\u5173\u6ce8\uff01<\/p>\n<p>\u672c\u6587\u6240\u6d89\u53ca\u7684\u6e90\u7801\u53ca\u5b89\u88c5\u5305\u5982\u4e0b\uff08\u7531\u4e8e\u5e73\u53f0\u9650\u5236\uff0c\u8bf7\u70b9\u51fb\u4ee5\u4e0b\u94fe\u63a5\u9605\u8bfb\u539f\u6587\u4e0b\u8f7d\uff09\uff1a<\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=0wSy3Kaik332jlgcbwSRTw%3D%3D.W63oO18bwuL%2FmDKOVD8IDHYt9FggNjMk7T%2FmW8gMtza9Y9UkAxmLn%2Fsm96U5dsbATInesMHWxvrRPCTJIyw2Qw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/hc-sr04-tutorial.html<\/a><\/p>\n<p>\u5982\u679c\u4f60\u662f\u5d4c\u5165\u5f0f\u5f00\u53d1\u5c0f\u767d\uff0c\u90a3\u4e48\u5efa\u8bae\u4f60\u5148\u8bfb\u8bfb\u4e0b\u9762\u51e0\u7bc7\u6587\u7ae0\u3002<\/p>\n<ul>\n<li>\u3010STM32\u4e0b\u8f7d\u7a0b\u5e8f\u7684\u4e94\u79cd\u65b9\u6cd5\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=7OLocP5wCvXp2UJ5t3nHxA%3D%3D.nM0ZzxS%2BnSJ7%2FndjqRgZxYLHrlY0SifY%2FI6FOD7xg%2FWQx%2Fk3hYuAzQvUs3BaXV%2F7iXUw9EPpnqrF1hEVoAkZwo8drZu2MbwrNK5bFqKnI34%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/five-ways-to-flash-program-to&#8230;<\/a>\u3011<\/li>\n<li>\u3010\u4e00\u6587\u6559\u4f60\u4f7f\u7528MDK\u5f00\u53d1\u5de5\u5177\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=oR4X%2BCYC%2F1LJpP%2FboGxBfw%3D%3D.l6aoQa4rV6w9jAFTNiYDprLTG0p5Rj3aaYqsZhX3GEq%2BJ5b5HK8xlze0ycinczuQ3VMpvMJPd7oEUfJLlNeuhjt4o1Ur8KORTcy8nRgD42Q%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/mdk-development-tool-tutorial&#8230;<\/a>\u3011<\/li>\n<li>\u3010\u96f6\u57fa\u7840\u5feb\u901f\u4e0a\u624bSTM32\u5f00\u53d1\uff08\u624b\u628a\u624b\u4fdd\u59c6\u7ea7\u6559\u7a0b\uff09\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=O7nrb%2Bq74cqF3gOj0JVqRw%3D%3D.Q%2BsM8j2aGQEvwdACK2LV6Io2KYPF48E4wEi7BxXdnUlg16yd2M4U4m3J8tpkWtAXPIZgalu%2FD22LAkkdxpFQ2fvaolPv90%2FSMDbXXePv8nQ%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/stm32-quick-start-for-beginne&#8230;<\/a>\u3011<\/li>\n<\/ul>\n<p>\u5f80\u671f\u6559\u7a0b\uff0c\u6709\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u770b\u770b\u3002<\/p>\n<ul>\n<li>\u3010\u624b\u628a\u624b\u6559\u4f60\u73a9\u8f6c\u84dd\u7259\u6a21\u5757\uff08\u539f\u7406+\u9a71\u52a8\uff09\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=sIKT2aAyrWHde%2Bt4w3EAtg%3D%3D.XuSeaiXtCVBW7KzXDVAKArR8VYM8Z0HQB7oN1ccn2YosZoeOpFogTRalhdZ9%2FHkbqNPKFm8YTfvSZH%2Fp8%2Bqi%2FQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/bluetooth-turorial.html<\/a>\u3011<\/li>\n<li>\u3010\u624b\u628a\u624b\u6559\u4f60\u73a9\u8f6cESP8266\uff08\u539f\u7406+\u9a71\u52a8\uff09\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=6GyNuW%2BBRB%2BnJDDoOi7qMg%3D%3D.fsUY%2FhgtJ8zqIttWvJMM6vxFGzNgKT0%2BYLO9ka6P8HQGkNOjhG4U0bMhLGoo%2FAvcVF789iWJhlhhDWlmYV7ffQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/esp8266-tutorial.html<\/a>\u3011<\/li>\n<li>\u3010\u624b\u628a\u624b\u6559\u4f60\u73a9\u8f6cDHT11\uff08\u539f\u7406+\u9a71\u52a8\uff09\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=Fvo3wqNPgBAobiL1jfLLkA%3D%3D.lZGK6QVMCuNySxBE2UgIOzhj%2BlpSLbf6wkvoCPZbLzJobkqYtm2rxY0rLQGWWThQkyrvewAhuc%2FiM4DpryAxGQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/dht11-tutorial.html<\/a>\u3011<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th align=\"left\">\u4f5c\u8005\u7b80\u4ecb<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"left\">\u5927\u5bb6\u597d\uff0c\u6211\u662f\u826f\u8bb8\uff0c\u535a\u5ba2\u91cc\u6240\u6709\u7684\u6587\u7ae0\u7686\u4e3a\u6211\u7684\u539f\u521b\u3002<br \/>\u4e0b\u9762\u662f\u6211\u7684\u4e00\u4e9b\u4e2a\u4eba\u4ecb\u7ecd\uff0c\u6b22\u8fce\u4ea4\u4e2a\u670b\u53cb\uff1a<br \/>\u00b7 211\u5de5\u79d1\u7855\u58eb\uff0c\u56fd\u5bb6\u5956\u5b66\u91d1\u83b7\u5f97\u8005\uff1b<br \/>\u00b7 \u6df1\u8015\u5d4c\u5165\u5f0f11\u5e74\uff0c\u524d\u4e16\u754c500\u5f3a\u5916\u4f01\u9ad8\u7ea7\u5d4c\u5165\u5f0f\u5de5\u7a0b\u5e08\uff1b<br \/>\u00b7 \u4e66\u7c4d\u300a\u901f\u5b66Linux\u4f5c\u8005\u300b\uff0c\u673a\u68b0\u5de5\u4e1a\u51fa\u7248\u793e\u4e13\u5bb6\u59d4\u5458\u4f1a\u6210\u5458\uff1b<br \/>\u00b7 \u5168\u7f5160W\u7c89\u4e1d\uff0c\u535a\u5ba2\u5206\u4eab\u5927\u91cf\u539f\u521b\u6210\u4f53\u7cfb\u6587\u7ae0\uff0c\u5168\u7f51\u9605\u8bfb\u91cf\u7d2f\u8ba1\u8d854000\u4e07\uff1b<br \/>\u00b7 \u9760\u81ea\u5a92\u4f53\u8fde\u7eed\u5e74\u5165\u767e\u4e07\uff0c\u9760\u81ea\u5df1\u4e70\u623f\u4e70\u8f66\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6211\u672c\u79d1\u53ca\u7855\u58eb\u90fd\u662f\u5b66\u673a\u68b0\uff0c\u901a\u8fc7\u81ea\u5b66\u6210\u529f\u8fdb\u5165\u4e16\u754c500\u5f3a\u5916\u4f01\u3002\u6211\u5df2\u7ecf\u5c06\u81ea\u5df1\u7684\u5b66\u4e60\u7ecf\u9a8c\u5199\u6210\u4e86\u4e00\u672c\u7535\u5b50\u4e66\uff0c\u8d85\u5343\u4eba\u901a\u8fc7\u6b64\u4e66\u5b66\u4e60\u5e76\u8f6c\u884c\u6210\u529f\u3002\u73b0\u5728\u5c06\u8fd9\u672c\u7535\u5b50\u4e66\u514d\u8d39\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u5e0c\u671b\u5bf9\u4f60\u4eec\u6709\u5e2e\u52a9\uff1a<\/p>\n<p>\u7535\u5b50\u4e66\u94fe\u63a5\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=jgMchpnd%2FLTUON07nghttQ%3D%3D.FAD8wK15Hd9NJ1%2Bxh9HUB5oCX393W34x7ET0rU2i7AjvMgFX64hNQQAJukT4GZuM\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/1024.html<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"392\" height=\"836\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfebd\" alt=\"\" title=\"\"><\/p>\n<h2>2. HC-SR04\u4ecb\u7ecd<\/h2>\n<p>\u8d85\u58f0\u6ce2\u4f20\u611f\u5668\u6709\u5f88\u591a\u7684\u4fe1\u53f7\uff1aHC-SR04\u3001UC-025\u3001UC-026\u3001UC-015\u3001US-100\u7b49\u7b49\uff0c\u5b83\u4eec\u4e4b\u95f4\u5927\u540c\u5c0f\u5f02\uff0c\u65e0\u975e\u662f\u5de5\u4f5c\u53c2\u6570\u6709\u70b9\u4e0d\u4e00\u6837\uff0c\u50cf\u662f\u5de5\u4f5c\u7684\u7535\u538b\u6216\u6e29\u5ea6\u3001\u63a2\u6d4b\u8ddd\u79bb\u6216\u7cbe\u5ea6\u6709\u70b9\u5dee\u522b\uff0c\u5f15\u811a\u662f\u4e00\u6837\u7684\uff0c\u90fd\u662f4\u4e2a\u5f15\u811a\uff08US-100 \u591a\u4e00\u4e2a GND \u5f15\u811a\uff09\uff0c\u5f15\u811a\u987a\u5e8f\u548c\u529f\u80fd\u4e5f\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"495\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgPU\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5927\u5bb6\u5728\u5b66\u4e60\u548c\u5de5\u4f5c\u4e2d\u53ef\u4ee5\u81ea\u884c\u9009\u62e9\u5408\u9002\u7684\u578b\u53f7\uff0c\u8fd9\u91cc\u6211\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u6700\u5e38\u89c1\u7684 HC-SR04 \u8fd9\u4e2a\u578b\u53f7\u3002<\/p>\n<h3>2.1 HC-SR04\u578b\u53f7\u4ecb\u7ecd<\/h3>\n<p>\u73b0\u5728\u5e02\u9762\u4e0a\u7684 HC- SR04 \u6709\u65b0\u7248\u548c\u65e7\u7248\uff0c\u6211\u4eec\u4ecb\u7ecd\u7684\u662f\u65b0\u7248\u3002\u65b0\u7248\u6027\u80fd\u6bd4\u8001\u7248\u7684\u7cbe\u5ea6\u66f4\u9ad8\uff0c\u6d4b\u8ddd\u8303\u56f4\u66f4\u8fdc\uff0c\u53ef\u8fbe6\u7c73\uff0c\u9ad8\u4e8e\u4e00\u822c\u8d85\u58f0\u6ce2\u6d4b\u8ddd\u6a21\u5757\u3002\u91c7\u7528 CS-100A \u8d85\u58f0\u6ce2\u6d4b\u8ddd SOC \u82af\u7247\uff0c\u9ad8\u6027\u80fd\uff0c\u5de5\u4e1a\u7ea7\uff0c\u5bbd\u7535\u538b\uff0c\u4ef7\u683c\u57284\u5757\u94b1\u5de6\u53f3\u3002<\/p>\n<h3>2.2 HC-SR04\u5de5\u4f5c\u53c2\u6570\u53ca\u5f15\u811a\u4ecb\u7ecd<\/h3>\n<p>HC-SR04 \u5de5\u4f5c\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\u63a2\u6d4b\u8ddd\u79bb\uff1a2~600cm<\/li>\n<li>\u63a2\u6d4b\u7cbe\u5ea6\uff1a0.1cm\u00b11%<\/li>\n<li>\u611f\u5e94\u89d2\u5ea6\uff1a&lt;15\u00b0<\/li>\n<li>\u8f93\u51fa\u65b9\u5f0f\uff1aGPIO<\/li>\n<li>\u5de5\u4f5c\u7535\u538b\uff1aDC 3~5.5V<\/li>\n<li>\u5de5\u4f5c\u7535\u6d41\uff1a5.3mA<\/li>\n<li>\u5de5\u4f5c\u6e29\u5ea6\uff1a-40~85\u2103<\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"709\" height=\"420\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgPV\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u63a5\u7ebf\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">HC-SR04<\/th>\n<th align=\"center\">STM32<\/th>\n<th align=\"center\">\u5907\u6ce8<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">VCC<\/td>\n<td align=\"center\">3.3\/5V<\/td>\n<td align=\"center\">\u5916\u63a5\u76f4\u6d41\u7535\u6e90<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Trig<\/td>\n<td align=\"center\">\u4efb\u610f\u4e00\u4e2aGPIO\u53e3<\/td>\n<td align=\"center\">\u8f93\u5165\u7aef<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Echo<\/td>\n<td align=\"center\">\u4efb\u610f\u4e00\u4e2aGPIO\u53e3<\/td>\n<td align=\"center\">\u8f93\u51fa\u7aef<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">GND<\/td>\n<td align=\"center\">GND<\/td>\n<td align=\"center\">\u63a5\u5730<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>3. HC-SR04\u5de5\u4f5c\u539f\u7406<\/h2>\n<h3>3.1 \u539f\u7406\u7b80\u8ff0<\/h3>\n<p>\u8d85\u58f0\u6ce2\u6d4b\u8ddd\u7684\u5de5\u4f5c\u539f\u7406\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u4f20\u611f\u5668\u53d1\u9001\u8d85\u58f0\u6ce2\uff0c\u8d85\u58f0\u6ce2\u78b0\u5230\u969c\u788d\u7269\u53cd\u5f39\u56de\u6765\uff0c\u88ab\u4f20\u611f\u5668\u63a5\u6536\u5230\u3002\u82af\u7247\u7b97\u51fa\u53d1\u9001\u548c\u63a5\u6536\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u518d\u5229\u7528\u516c\u5f0f\uff1as = v \u00d7 t\uff0c\u770b\u4e0b\u9762\u793a\u610f\u56fe\uff0c\u6240\u4ee5\u5b9e\u9645\u8ddd\u79bb = \u6d4b\u91cf\u8ddd\u79bb \/ 2 =  \u901f\u5ea6 \u00d7 \u65f6\u95f4 \/ 2\u3002<\/p>\n<p>\u987a\u4fbf\u4e00\u63d0\uff0c\u8d85\u58f0\u6ce2\u5728\u7a7a\u6c14\u4e2d\u7684\u4f20\u64ad\u901f\u5ea6\u5927\u6982\u662f 343m\/s\uff0c\u4f20\u64ad\u901f\u5ea6\u53d7\u5230\u73af\u5883\u6761\u4ef6\u7684\u5f71\u54cd\uff0c\u5982\u6e29\u5ea6\u3001\u6e7f\u5ea6\u548c\u6c14\u538b\u7b49\u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"397\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgPW\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8d85\u58f0\u6ce2\u6a21\u5757\u4e0a\u7684\u4e24\u4e2a\u8d85\u58f0\u6ce2\u63a2\u5934\uff0c\u4e00\u4e2a\u662f\u53d1\u9001\u7aef\uff0c\u8d1f\u8d23\u53d1\u9001\u8d85\u58f0\u6ce2\uff1b\u4e00\u4e2a\u662f\u63a5\u6536\u7aef\uff0c\u8d1f\u8d23\u63a5\u6536\u8d85\u58f0\u6ce2\u3002<\/p>\n<h3>3.2 \u539f\u7406\u8be6\u8ff0<\/h3>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u8be6\u7ec6\u7684\u4ecb\u7ecd\u4e0b\u8d85\u58f0\u6ce2\u6a21\u5757\u7684\u5de5\u4f5c\u65f6\u5e8f\uff0c\u660e\u767d\u4e86\u65f6\u5e8f\u4ee5\u540e\u624d\u77e5\u9053\u600e\u4e48\u5199\u4ee3\u7801\u3002<\/p>\n<ul>\n<li><strong>\u6b63\u5e38\u6d4b\u8ddd\u65f6\u5e8f\u56fe\uff1a<\/strong><\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"723\" height=\"287\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgPX\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<ol>\n<li>\u5355\u7247\u673a\u7ed9\u8d85\u58f0\u6ce2\u6a21\u5757\u53d1\u9001\u5927\u4e8e 10us \u7684\u9ad8\u7535\u5e73\u7684\u89e6\u53d1\u4fe1\u53f7\uff1b<\/li>\n<li>\u8d85\u58f0\u6ce2\u6a21\u5757\u6536\u5230\u89e6\u53d1\u4fe1\u53f7\u540e Trig \u7aef\u53d1\u9001 8\u4e2a40kHz \u7684\u8d85\u58f0\u6ce2\u8109\u51b2\uff1b<\/li>\n<li>Echo \u7aef\u7531\u4f4e\u7535\u5e73\u8f6c\u4e3a\u9ad8\u7535\u5e73\uff0c\u540c\u65f6\u5f00\u59cb\u53d1\u9001\u8d85\u58f0\u6ce2\uff1b<\/li>\n<li>\u8d85\u58f0\u6ce2\u6a21\u5757\u68c0\u6d4b\u5230\u8fd4\u56de\u4fe1\u53f7\uff0cEcho \u7aef\u7531\u9ad8\u7535\u5e73\u8f6c\u4e3a\u4f4e\u7535\u5e73\uff1b<\/li>\n<li>Echo \u7aef\u9ad8\u7535\u5e73\u5bbd\u5ea6\u5373\u4e3a\u8d85\u58f0\u6ce2\u4f20\u64ad\u65f6\u95f4\u3002<\/li>\n<\/ol>\n<p>\u5982\u679c\u89c9\u5f97\u592a\u751f\u6da9\u4e86\uff0c\u6211\u7ed9\u5927\u5bb6\u51c6\u5907\u4e86\u8da3\u5473\u63cf\u8ff0\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"380\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgPY\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<ul>\n<li><strong>\u8d85\u51fa\u6d4b\u8ddd\u8303\u56f4\u65f6\u5e8f\u56fe\uff1a<\/strong><\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"723\" height=\"287\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgPZ\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5f53\u6d4b\u91cf\u8ddd\u79bb\u8d85\u8fc7 HC-SR04 \u7684\u6d4b\u91cf\u8303\u56f4\u65f6\uff0cEcho \u4efb\u4f1a\u8f93\u51fa\u9ad8\u7535\u5e73\uff0c\u5bbd\u5ea6\u7ea6\u4e3a66ms\uff0c\u540e\u8f6c\u4e3a\u4f4e\u7535\u5e73\u3002<\/p>\n<h2>4. \u7f16\u7a0b\u5b9e\u6218<\/h2>\n<h3>4.1 \u786c\u4ef6\u63a5\u7ebf<\/h3>\n<p>\u672c\u6559\u7a0b\u4f7f\u7528\u7684\u786c\u4ef6\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u5355\u7247\u673a\uff1aSTM32F103C8T6<\/li>\n<li>\u8d85\u58f0\u6ce2\u4f20\u611f\u5668\uff1aHC-SR04<\/li>\n<li>\u4e32\u53e3\uff1aUSB \u8f6c TTL<\/li>\n<li>\u70e7\u5f55\u5668\uff1aST-LINK V2<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th align=\"center\">HC-SR04<\/th>\n<th align=\"center\">STM32<\/th>\n<th align=\"center\">USB \u8f6c TTL<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">VCC<\/td>\n<td align=\"center\">3.3\/5V<\/td>\n<td align=\"center\"> <\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Trig<\/td>\n<td align=\"center\">B6<\/td>\n<td align=\"center\"> <\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Echo<\/td>\n<td align=\"center\">B7<\/td>\n<td align=\"center\"> <\/td>\n<\/tr>\n<tr>\n<td align=\"center\">GND<\/td>\n<td align=\"center\">G<\/td>\n<td align=\"center\"> <\/td>\n<\/tr>\n<tr>\n<td align=\"center\"> <\/td>\n<td align=\"center\">A10<\/td>\n<td align=\"center\">TX<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"> <\/td>\n<td align=\"center\">A9<\/td>\n<td align=\"center\">RX<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"> <\/td>\n<td align=\"center\">G<\/td>\n<td align=\"center\">GND<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u70e7\u5f55\u7684\u65f6\u5019\u63a5\u7ebf\u5982\u4e0b\u8868\uff0c\u5982\u679c\u4e0d\u4f1a\u70e7\u5f55\u7684\u8bdd\u53ef\u4ee5\u770b\u6211\u4e4b\u524d\u7684\u6587\u7ae0\u3010STM32\u4e0b\u8f7d\u7a0b\u5e8f\u7684\u4e94\u79cd\u65b9\u6cd5\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=2QufUUmN5uB4YGwQt7NzvA%3D%3D.bMT1iRfiOrc2Pfm4Wp1XOVequFyJtK58%2BTu6S9eV9owxnQP1IKTSUa249WFyvbcdbn4pber3GhiH6EI%2F%2BsEfnrVeA2tyXHzSRAbdHIjuUfM%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.lxlinux.net\/e\/stm32\/five-ways-to-flash-program-to&#8230;<\/a>\u3011\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">ST-Link V2<\/th>\n<th align=\"center\">STM32<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">SWCLK<\/td>\n<td align=\"center\">SWCLK<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">SWDIO<\/td>\n<td align=\"center\">SWDIO<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">GND<\/td>\n<td align=\"center\">GND<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">3.3V<\/td>\n<td align=\"center\">3V3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u63a5\u597d\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"491\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgP0\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>4.2 \u521d\u59cb\u5316\u5f15\u811a<\/h3>\n<p>\u6211\u4eec\u5c06 Trig \u5f15\u811a\u8bbe\u7f6e\u4e3a\u63a8\u633d\u5f0f\u8f93\u51fa\uff0cEcho \u5f15\u811a\u8bbe\u7f6e\u4e3a\u6d6e\u7a7a\u8f93\u5165\u3002\u4e3a\u4ec0\u4e48\u8fd9\u6837\u8bbe\u7f6e\u5462\uff1f\u5927\u5bb6\u53ef\u4ee5\u5bf9\u7167\u4e0b\u8868\u7684 GPIO \u7684\u516b\u79cd\u5de5\u4f5c\u6a21\u5f0f\u770b\u770b\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u6a21\u5f0f\u540d\u79f0<\/th>\n<th align=\"center\">\u6027\u8d28<\/th>\n<th align=\"center\">\u7279\u5f81<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\u6d6e\u7a7a\u8f93\u5165<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u53ef\u8bfb\u53d6\u5f15\u811a\u7535\u5e73\uff0c\u82e5\u5f15\u811a\u60ac\u7a7a\uff0c\u5219\u7535\u5e73\u4e0d\u786e\u5b9a<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u4e0a\u62c9\u8f93\u5165<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u53ef\u8bfb\u53d6\u5f15\u811a\u7535\u5e73\uff0c\u5185\u90e8\u8fde\u63a5\u4e0a\u62c9\u7535\u963b\uff0c\u60ac\u7a7a\u65f6\u9ed8\u8ba4\u9ad8\u7535\u5e73<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u4e0b\u62c9\u8f93\u5165<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u53ef\u8bfb\u53d6\u5f15\u811a\u7535\u5e73\uff0c\u5185\u90e8\u8fde\u63a5\u4e0b\u62c9\u7535\u963b\uff0c\u60ac\u7a7a\u65f6\u9ed8\u8ba4\u4f4e\u7535\u5e73<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u6a21\u62df\u8f93\u5165<\/td>\n<td align=\"center\">\u6a21\u62df\u8f93\u5165<\/td>\n<td align=\"center\">GPIO \u65e0\u6548\uff0c\u5f15\u811a\u76f4\u63a5\u63a5\u5165\u5185\u90e8 ADC<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u5f00\u6f0f\u8f93\u51fa<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u53ef\u8f93\u51fa\u5f15\u811a\u7535\u5e73\uff0c\u9ad8\u7535\u5e73\u4e3a\u9ad8\u963b\u6001\uff0c\u4f4e\u7535\u5e73\u63a5 VSS<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u63a8\u633d\u8f93\u51fa<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u53ef\u8f93\u51fa\u5f15\u811a\u7535\u5e73\uff0c\u9ad8\u7535\u5e73\u63a5 VDD\uff0c\u4f4e\u7535\u5e73\u63a5 VSS<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u590d\u7528\u5f00\u6f0f\u8f93\u51fa<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u7531\u7247\u4e0a\u5916\u8bbe\u63a7\u5236\uff0c\u9ad8\u7535\u5e73\u4e3a\u9ad8\u963b\u6001\uff0c\u4f4e\u7535\u5e73\u63a5VSS<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u590d\u7528\u63a8\u633d\u8f93\u51fa<\/td>\n<td align=\"center\">\u6570\u5b57\u8f93\u5165<\/td>\n<td align=\"center\">\u7531\u7247\u4e0a\u5916\u8bbe\u63a7\u5236\uff0c\u9ad8\u7535\u5e73\u63a5VDD\uff0c\u4f4e\u7535\u5e73\u63a5VSS<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5f15\u811a\u521d\u59cb\u5316\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"c\"> void HCSR04_GPIO_init(void)\n{\n    GPIO_InitTypeDef GPIO_InitStruct = {0};\n\n    Trig_GPIO_CLK_ENABLE();                                 \/* Trig\u5f15\u811a\u4f7f\u80fd *\/\n    Echo_GPIO_CLK_ENABLE();                                 \/* Echo\u5f15\u811a\u4f7f\u80fd *\/\n\n    \/* Trig\u4f4e\u7535\u5e73 *\/\n    HAL_GPIO_WritePin(Trig_GPIO_PORT, Trig_GPIO_PIN, GPIO_PIN_RESET);\n\n    GPIO_InitStruct.Pin = Trig_GPIO_PIN;                   \/* Trig\u5f15\u811a *\/\n    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;            \/* \u63a8\u633d\u8f93\u51fa *\/\n    GPIO_InitStruct.Pull = GPIO_NOPULL;                    \/* \u6d6e\u7a7a *\/\n    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;           \/* \u4f4e\u901f *\/\n    HAL_GPIO_Init(Trig_GPIO_PORT, &amp;GPIO_InitStruct);       \/* \u521d\u59cb\u5316Trig\u5f15\u811a *\/\n\n    GPIO_InitStruct.Pin = Echo_GPIO_PIN;                   \/* Echo\u5f15\u811a *\/\n    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;                \/* \u8f93\u5165 *\/\n    GPIO_InitStruct.Pull = GPIO_NOPULL;                    \/* \u6d6e\u7a7a *\/\n    HAL_GPIO_Init(Echo_GPIO_PORT, &amp;GPIO_InitStruct);       \/* \u521d\u59cb\u5316Echo\u5f15\u811a *\/\n}<\/code><\/pre>\n<h3>4.3 \u521d\u59cb\u5316\u5b9a\u65f6\u5668<\/h3>\n<p>\u9700\u8981\u521d\u59cb\u5316\u4e00\u4e2a\u5b9a\u65f6\u5668\uff0c\u7528\u4e8e\u6d4b\u91cf Echo \u9ad8\u7535\u5e73\u5bbd\u5ea6\uff0c\u8fd9\u91cc\u6211\u4eec\u521d\u59cb\u5316\u4e86\u901a\u7528\u5b9a\u65f6\u56682\u3002<\/p>\n<pre><code class=\"c\">void TIM2_Init(void)\n{\n    TIM_ClockConfigTypeDef sClockSourceConfig = {0};            \/* \u5b9a\u65f6\u5668\u8bbe\u7f6e\u7ed3\u6784\u4f53 *\/\n    TIM_MasterConfigTypeDef sMasterConfig = {0};\n\n    htim2.Instance = TIM2;                                      \/* \u901a\u7528\u5b9a\u65f6\u56682 *\/\n    htim2.Init.Prescaler = 71;                                  \/* \u9884\u5206\u9891\u7cfb\u6570 *\/\n    htim2.Init.CounterMode = TIM_COUNTERMODE_UP;                \/* \u9012\u589e\u8ba1\u6570\u6a21\u5f0f *\/\n    htim2.Init.Period = 65535;                                  \/* \u81ea\u52a8\u88c5\u8f7d\u503c *\/\n    htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;\n    htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;\n    HAL_TIM_Base_Init(&amp;htim2);\n\n    sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;\n    HAL_TIM_ConfigClockSource(&amp;htim2, &amp;sClockSourceConfig);\n\n    sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;\n    sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;\n    HAL_TIMEx_MasterConfigSynchronization(&amp;htim2, &amp;sMasterConfig);\n}<\/code><\/pre>\n<h3>4.4 \u6d4b\u91cf\u8ddd\u79bb<\/h3>\n<p>\u6309\u7167\u8d85\u58f0\u6ce2\u7684\u5de5\u4f5c\u65f6\u5e8f\uff0c<\/p>\n<ol>\n<li>\u5355\u7247\u673a\u7ed9\u8d85\u58f0\u6ce2\u6a21\u5757\u53d1\u9001\u5927\u4e8e 10us \u7684\u9ad8\u7535\u5e73\u7684\u89e6\u53d1\u4fe1\u53f7\uff1b<\/li>\n<li>Trig \u7684 8\u4e2a40kHz \u7684\u8d85\u58f0\u6ce2\u8109\u51b2\uff0c\u4e0d\u7528\u7ba1\uff0c\u6211\u4eec\u4e0d\u9700\u8981\uff1b<\/li>\n<li>Echo \u7aef\u7531\u4f4e\u7535\u5e73\u8f6c\u4e3a\u9ad8\u7535\u5e73\uff0c\u5f00\u542f\u5b9a\u65f6\u5668\uff1b<\/li>\n<li>\u8d85\u58f0\u6ce2\u6a21\u5757\u68c0\u6d4b\u5230\u8fd4\u56de\u4fe1\u53f7\uff0cEcho \u7aef\u7531\u9ad8\u7535\u5e73\u8f6c\u4e3a\u4f4e\u7535\u5e73\uff0c\u5173\u95ed\u5b9a\u65f6\u5668\uff1b<\/li>\n<li>\u5f97\u5230\u8d85\u58f0\u6ce2\u6765\u56de\u7684\u603b\u8ddd\u79bb\uff0c\u8fdb\u884c\u8ba1\u7b97\uff0c\u5f97\u5230\u5b9e\u9645\u6d4b\u91cf\u8ddd\u79bb\u3002<\/li>\n<\/ol>\n<pre><code class=\"c\">void HCSR04_Get_Length (void)  \n{  \n    int total_time=0;           \/\/\u8d85\u58f0\u6ce2\u6765\u56de\u7684\u603b\u65f6\u95f4\n    float distance=0;           \/\/\u5b9e\u9645\u6d4b\u91cf\u8ddd\u79bb\n\n    HCSR04_GPIO_init();\n    HAL_GPIO_WritePin(Trig_GPIO_PORT,Trig_GPIO_PIN,GPIO_PIN_SET);           \/\/\u62c9\u9ad8\n    __HAL_TIM_SetCounter(&amp;htim2, 0);                                        \/\/\u5b9a\u65f6\u5668\u5f52\u96f6\n    delay_us(15);\n    HAL_GPIO_WritePin(Trig_GPIO_PORT,Trig_GPIO_PIN,GPIO_PIN_RESET);         \/\/\u62c9\u4f4e\n\n    while(HAL_GPIO_ReadPin(Echo_GPIO_PORT,Echo_GPIO_PIN)==GPIO_PIN_RESET);  \/\/Echo\u8f6c\u5230\u9ad8\u7535\u5e73\n    HAL_TIM_Base_Start(&amp;htim2);                                             \/\/\u542f\u52a8\u5b9a\u65f6\u5668\n\n    while(HAL_GPIO_ReadPin(Echo_GPIO_PORT,Echo_GPIO_PIN)==GPIO_PIN_SET);    \/\/Echo\u8f6c\u56de\u4f4e\u7535\u5e73\n    HAL_TIM_Base_Stop(&amp;htim2);                                              \/\/\u505c\u6b62\u5b9a\u65f6\u5668\n\n    total_time = __HAL_TIM_GetCounter(&amp;htim2);                              \/\/\u5f97\u5230\u9ad8\u7535\u5e73\u6301\u7eed\u65f6\u95f4\n\n    distance = total_time * 0.01715; \/\/                                     \/\/\u7b97\u51fa\u6d4b\u91cf\u8ddd\u79bb\uff08343*0.000001*100\/2 = 0.01715\uff09\n    printf(&quot;dis : %.2f cm\/r\/n&quot;,distance);\n}<\/code><\/pre>\n<p>\u6709\u7684\u540c\u5b66\u53ef\u80fd\u4f1a\u597d\u5947\uff0c\u8fd9\u4e2a\u201c * 0.01715 \u201d\u662f\u4ec0\u4e48\uff0c\u56e0\u4e3a<\/p>\n<p>\u5b9e\u9645\u8ddd\u79bb = \u6d4b\u91cf\u8ddd\u79bb \/ 2 <\/p>\n<p>\u200b                =  \u901f\u5ea6 \u00d7 \u603b\u65f6\u95f4 \/ 2\u3002<\/p>\n<p>\u200b                = 343\uff08m\/s\uff09 * total_time\uff08us\uff09\/ 2<\/p>\n<p>\u200b                = 343\uff08m\/s\uff09 <em> total_time\uff08us\uff09 <\/em> 0.000001\uff081s=1000000\uff09 * 100\uff081m=100cm\uff09\/2<\/p>\n<p>\u200b                = 343 <em> 0.000001 <\/em> 100 \/ 2<\/p>\n<p>\u200b                = 0.01715<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u5c31\u76f4\u63a5\u5199 0.01715 \u5566\uff0c\u51cf\u8f7b\u4e00\u70b9\u8ba1\u7b97\u8d1f\u62c5\uff0c\u867d\u7136\u672c\u8eab\u4e5f\u6ca1\u591a\u5c11\u3002<\/p>\n<p>.h\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"c\">#ifndef __HCSR04_H__\n#define __HCSR04_H__\n\n#include &quot;stdio.h&quot;\n#include &quot;stm32f1xx.h&quot;\n\n\/* \u5f15\u811a\u5b9a\u4e49 *\/\n#define Trig_GPIO_PORT                  GPIOB\n#define Trig_GPIO_PIN                   GPIO_PIN_6\n#define Trig_GPIO_CLK_ENABLE()          do{ __HAL_RCC_GPIOB_CLK_ENABLE(); }while(0)             \/* PB\u53e3\u65f6\u949f\u4f7f\u80fd *\/\n\n#define Echo_GPIO_PORT                  GPIOB\n#define Echo_GPIO_PIN                   GPIO_PIN_7\n#define Echo_GPIO_CLK_ENABLE()          do{ __HAL_RCC_GPIOB_CLK_ENABLE(); }while(0)             \/* PB\u53e3\u65f6\u949f\u4f7f\u80fd *\/\n\n\n\nvoid HCSR04_GPIO_init(void);\nvoid TIM2_Init(void);\nvoid HCSR04_Get_Length (void);\n\n#endif\n<\/code><\/pre>\n<h3>4.5 \u6700\u7ec8\u6548\u679c<\/h3>\n<p>\u4e32\u53e3\u8f93\u51fa\u5982\u4e0b\uff0c\u8fd9\u662f\u6211\u7528\u672c\u5b50\u5728\u8d85\u58f0\u6ce2\u524d\u6765\u56de\u79fb\u52a8\u7684\u6570\u636e\u3002\u8bb0\u5f97\u7ed9\u677f\u5b50\u4e0a\u7535\u54e6\uff0c\u5149 STLink \u4f9b\u7535\u53ef\u4e0d\u591f\u3002<\/p>\n<p><img decoding=\"async\" width=\"592\" height=\"567\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdfgP1\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>5. \u5c0f\u7ed3<\/h2>\n<h2>\u901a\u8fc7\u672c\u6587\u7684\u5b66\u4e60\u4e0e\u5b9e\u8df5\uff0c\u76f8\u4fe1\u5927\u5bb6\u5df2\u7ecf\u4e86\u89e3\u5e76\u638c\u63e1 HC-SR04 \u7684\u7279\u6027\u548c\u4f7f\u7528\uff0c\u80fd\u591f\u66f4\u597d\u5730\u5e94\u7528\u4e8e\u5d4c\u5165\u5f0f\u5f00\u53d1\u3002\u5e0c\u671b HC-SR04 \u53ef\u4ee5\u6210\u4e3a\u60a8\u7684\u5f97\u529b\u52a9\u624b\uff0c\u8ba9\u6211\u4eec\u4e00\u8d77\u73a9\u8f6c HC-SR04\uff0cpeace and love\uff01<\/h2>\n<p><strong>\u53e6\u5916\uff0c\u60f3\u8fdb\u5927\u5382\u7684\u540c\u5b66\uff0c\u4e00\u5b9a\u8981\u597d\u597d\u5b66\u7b97\u6cd5\uff0c\u8fd9\u662f\u9762\u8bd5\u5fc5\u5907\u7684\u3002\u8fd9\u91cc\u51c6\u5907\u4e86\u4e00\u4efd BAT \u5927\u4f6c\u603b\u7ed3\u7684 LeetCode \u5237\u9898\u5b9d\u5178\uff0c\u5f88\u591a\u4eba\u9760\u5b83\u4eec\u8fdb\u4e86\u5927\u5382\u3002<\/strong><\/p>\n<p><img decoding=\"async\" width=\"286\" height=\"83\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdaCCY\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=8TkeEah8KmA0am8r6tZ8Cg%3D%3D.ELUCHTM0mGrwDKVYQnmDJjOPf0HwdOMFC7FnGyv9TUduanXKB54j53euiZ3ctIJH\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u5237\u9898 | LeetCode\u7b97\u6cd5\u5237\u9898\u795e\u5668\uff0c\u770b\u5b8c BAT \u968f\u4f60\u6311\uff01<\/a><\/p>\n<h3>\u6709\u6536\u83b7\uff1f\u5e0c\u671b\u8001\u94c1\u4eec\u6765\u4e2a\u4e09\u8fde\u51fb\uff0c\u7ed9\u66f4\u591a\u7684\u4eba\u770b\u5230\u8fd9\u7bc7\u6587\u7ae0<\/h3>\n<p><strong>\u63a8\u8350\u9605\u8bfb\uff1a<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=Xao%2Bd64jraOYMkfRDCPxvQ%3D%3D.VgYOOl8z6Mw4D4GQeXRG7K4YRK6L9R5R8gxMQ2pjJt2BG3yv3byV0VA8sc3T51gS\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u7a0b\u5e8f\u5458\u5fc5\u5907\u7f16\u7a0b\u8d44\u6599\u5927\u5168<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=hmYlRB69cvzsi0qEXMPcDQ%3D%3D.rgA1BlHlEhyE3Gim%2FxN1qtOc%2FKlG3EihOzxTou17ukcSDx8ZcdvU%2BbGA66TIoqwJ\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u7a0b\u5e8f\u5458\u5fc5\u5907\u8f6f\u4ef6\u8d44\u6e90<\/a><\/li>\n<\/ul>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u535a\u5ba2\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=cPgze%2BnQ2Tuhzpga0JPrNQ%3D%3D.pCAYX2ZiVc7C%2FOywBFgrOsBoOFBAbyyygNk0%2B1A3nGg%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u826f\u8bb8\u5d4c\u5165\u5f0f\u6559\u7a0b\u7f51<\/a>\uff0c\u6ee1\u6ee1\u90fd\u662f\u5e72\u8d27\uff01<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000045546308\">https:\/\/segmentfault.com\/a\/1190000045546308<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u90fd\u77e5\u9053\u58f0\u97f3\u662f\u7531\u7269\u4f53\u632f\u52a8\u4ea7\u751f\u7684\uff0c\u4eba\u80fd\u542c\u5230\u7684\u9891\u7387\u572820Hz~20kHz\u3002\u9891\u7387\u5c0f\u4e8e20Hz\u7684\u53eb\u6b21\u58f0\u6ce2\uff0c\u9891\u7387\u5927\u4e8e2 [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020444","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020444"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020444\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}