{"id":85,"date":"2015-02-04T16:50:52","date_gmt":"2015-02-04T08:50:52","guid":{"rendered":"http:\/\/192.168.100.100\/wordpress\/2015\/02\/04\/arduino-%e6%96%b0%e6%89%8b%e5%af%a6%e4%bd%9c%e4%ba%94-%e8%b6%85%e9%9f%b3%e6%b3%a2%e6%87%89%e7%94%a8%e5%80%92%e8%bb%8a%e9%9b%b7%e9%81%94\/"},"modified":"2023-01-28T15:06:00","modified_gmt":"2023-01-28T07:06:00","slug":"arduino-%e6%96%b0%e6%89%8b%e5%af%a6%e4%bd%9c%e4%ba%94-%e8%b6%85%e9%9f%b3%e6%b3%a2%e6%87%89%e7%94%a8%e5%80%92%e8%bb%8a%e9%9b%b7%e9%81%94","status":"publish","type":"post","link":"https:\/\/blog.godzeng.com\/?p=85","title":{"rendered":"Arduino \u65b0\u624b\u5be6\u4f5c(\u4e94)  \u8d85\u97f3\u6ce2\u61c9\u7528(\u5012\u8eca\u96f7\u9054)"},"content":{"rendered":"<p><span style=\"font-size: 12pt;\">\u5927\u5bb6\u597d \u6211\u662f\u963f\u4fca \u4e0a\u6b21\u5229\u7528\u7d05\u5916\u7dda\u7684\u7279\u6027 \u4f86\u9054\u6210\u5075\u6e2c\u7269\u9ad4\u7684\u611f\u61c9 \u9019\u6b21\u8981\u4f7f\u7528\u8d85\u97f3\u6ce2\u7684\u7279\u6027\u4f86\u9054\u6210\u5075\u6e2c\u7269\u9ad4\u548c\u4e4b\u9593\u7684\u8ddd\u96e2 \u4f86\u9054\u6210\u4e8b\u4ef6\u7684\u4f5c\u52d5\u61c9\u7528 \u5728\u73fe\u5be6\u751f\u6d3b\u4e2d \u67d0\u4e9b\u6c7d\u8eca\u5012\u8eca\u6642 \u6703\u555f\u52d5\u5f8c\u4fdd\u96aa\u687f\u4e0a\u7684 \u8d85\u97f3\u6ce2\u6a21\u7d44 \u85c9\u7531 \u8072\u6ce2\u53cd\u5c04\u7279\u6027 \u4f86\u9054\u6210 \u4e0d\u540c\u7684\u8ddd\u96e2\u6709\u4e0d\u540c\u7684\u8b66\u5831\u8072 \u8b93\u99d5\u99db\u80fd\u5920\u8fa8\u5225\u662f\u5426\u5feb\u649e\u5230\u5f8c\u65b9\u7269\u9ad4\u7684\u9632\u649e\u6a5f\u5236 \u5148\u4f86\u5be6\u4f5c\u5f97\u5f71\u7247\u5427~~~<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><br \/>\n<script src=\"http:\/\/ext.pixnet.tv\/user\/o4043380\/embed\/movie\/574451965.js\" type=\"text\/javascript\"><\/script><br \/>\n&nbsp;&nbsp;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u4f55\u70ba\u8d85\u97f3\u6ce2?<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><strong>\u8d85\u97f3\u6ce2<\/strong>(<span lang=\"en\">Ultrasound<\/span>\u3001\u8d85\u97f3\u6ce2)\u662f\u6307\u4efb\u4f55<a style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u8072\u6ce2\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E5%A3%B0%E6%B3%A2\">\u8072\u6ce2<\/a>\u6216<a class=\"mw-redirect\" style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u632f\u52d5\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E6%8C%AF%E5%8B%95\">\u632f\u52d5<\/a>\uff0c\u5176<a style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u983b\u7387\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E9%A0%BB%E7%8E%87\">\u983b\u7387<\/a>\u8d85\u904e\u4eba\u985e\u8033\u6735\u53ef\u4ee5\u807d\u5230\u7684\u6700\u9ad8\u95be\u503c20kHz\uff08<a style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u8d6b\u8332\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E8%B5%AB%E5%85%B9\">\u5343\u8d6b<\/a>\uff09\u3002\u8d85\u97f3\u6ce2\u7531\u65bc\u5176\u9ad8\u983b\u7279\u6027\u800c\u88ab\u5ee3\u6cdb\u61c9\u7528\u65bc\u773e\u591a\u9818\u57df\uff0c\u6bd4\u5982\u91d1\u5c6c\u63a2\u50b7\uff0c\u5de5\u4ef6\u6e05\u6d17\u7b49\u3002<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">\u67d0\u4e9b\u52d5\u7269\uff0c\u5982<a class=\"mw-redirect\" style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u72d7\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E7%8B%97\">\u72d7\u96bb<\/a>\u3001<a style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u6d77\u8c5a\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E6%B5%B7%E8%B1%9A\">\u6d77\u8c5a<\/a>\u3001\u4ee5\u53ca<a style=\"text-decoration: none; color: #0b0080; background: none;\" title=\"\u8759\u8760\" href=\"http:\/\/zh.wikipedia.org\/wiki\/%E8%9D%99%E8%9D%A0\">\u8759\u8760<\/a>\u7b49\u7b49\u90fd\u6709\u8457\u8d85\u4e4e\u4eba\u985e\u7684\u8033\u6735\uff0c\u4e5f\u56e0\u6b64\u53ef\u4ee5\u807d\u5230\u8d85\u97f3\u6ce2\u3002\u4ea6\u6709\u4eba\u5229\u7528\u9019\u500b\u7279\u6027\u88fd\u6210\u80fd\u7522\u751f\u8d85\u97f3\u6ce2\u4f86\u547c\u559a\u72d7\u96bb\u7684<a class=\"new\" style=\"text-decoration: none; color: #a55858; background: none;\" title=\"\u72ac\u7b1b (\u9801\u9762\u4e0d\u5b58\u5728)\" href=\"http:\/\/zh.wikipedia.org\/w\/index.php?title=%E7%8A%AC%E7%AC%9B&amp;action=edit&amp;redlink=1\">\u72ac\u7b1b<\/a>\u3002(\u53d6\u81f3\u7dad\u57fa)<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">\u6c92\u932f\u6b63\u5e38\u4eba\u662f\u807d\u4e0d\u5230 \u8d85\u97f3\u6ce2 \u61c9\u5176\u983b\u7387\u592a\u9ad8 \u8d85\u904e\u8033\u6735\u53ef\u4ee5\u807d\u5230\u7684\u7bc4\u570d \u4e5f\u56e0\u70ba\u9019\u6a23 \u4f7f\u7528\u8a72\u7279\u6027 \u4f86\u9054\u6210 \u751f\u6d3b\u4e2d\u6240\u904b\u7528\u5230\u7684\u4fbf\u5229\u5de5\u5177<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\"><img title=\"\u8d85\u97f3\u6ce2\u539f\u7406\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1423041073-3207929197.png\" alt=\"\u8d85\u97f3\u6ce2\u539f\u7406\" border=\"0\" \/> &nbsp;<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\"><a href=\"http:\/\/o4043380.pixnet.net\/album\/photo\/574478935\"><img title=\"\u8d85\u8072\u6ce2\u6750\u6599\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1423041279-589746041_n.jpg\" alt=\"\u8d85\u8072\u6ce2\u6750\u6599\" border=\"0\" \/><\/a> &nbsp;<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">&nbsp;&nbsp;<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">\u6e96\u5099\u6750\u6599<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">Arduino X 1<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\">\u9023\u63a5\u7dda X N<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\">\u8702\u9cf4\u5668 X1<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\">\u8d85\u97f3\u6ce2\u6a21\u7d44 X1&nbsp;<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\">\u5b98\u65b9\u7a0b\u5f0f\u7de8\u8b6f\u5668 &nbsp;<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\">\u9eb5\u5305\u677f<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\"><a href=\"http:\/\/tetrasys-design.net\/download\/HCSR04Ultrasonic\/HCSR04Ultrasonic-1.1.2.zip\">\u8d85\u97f3\u6ce2\u7a0b\u5f0f\u5eab<\/a>&nbsp;\u4e0b\u8f09\u5f8c\u89e3\u58d3\u5230C:\\Program Files (x86)\\Arduino\\libraries<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\">\u8d85\u97f3\u6ce2\u6a21\u7d44\u6211\u5247\u662f\u4f7f\u7528HC-SR04&nbsp;<span style=\"color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 12pt; line-height: 16.8999996185303px;\">\u63a2\u6e2c\u7684\u8ddd\u96e2\u70ba 2cm-400cm\uff0c\u7cbe\u5ea6\u70ba 0.3 cm\u611f\u61c9\u89d2\u5ea6\u70ba 15 \u5ea6 \u50f9\u683c \u5dee\u4e0d\u591a100\u5167\u6709\u627e<\/span><\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 16px;\"><span style=\"color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 12pt; line-height: 16.8999996185303px;\"><a style=\"font-family: sans-serif; font-size: 16px; line-height: 22.3999996185303px;\" href=\"http:\/\/o4043380.pixnet.net\/album\/photo\/574479247\"><img title=\"hc04\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1423041352-4152556673_n.jpg\" alt=\"hc04\" border=\"0\" \/><\/a><\/span><\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">\u63a5\u4e0b\u4f86\u662f\u96fb\u8def\u5716<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\"><img title=\"\u96fb\u8def\u5716\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1423041680-2341647004_n.png?v=1423041681\" alt=\"\u96fb\u8def\u5716\" border=\"0\" \/> &nbsp;<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">SR04 \u63a5\u7dda\u96fb\u8def \u4e0d\u6703\u592a\u96e3 4\u96bb\u8173 \u6309\u7167\u5716\u63a5\u4e0d\u592a\u6703\u6709\u554f\u984c <span style=\"color: #ff0000;\">\u5176\u4e2dTrig \u548c Echo &nbsp; Trig\u662f \u767c\u9001 40KHz \u8d85\u8072\u6ce2\u7d66\u7269\u9ad4 &nbsp;Echo\u662f\u63a5\u6536 Trig\u78b0\u649e\u7269\u9ad4\u53cd\u5c04\u56de\u4f86\u7684\u8d85\u8072\u6ce2<\/span> &nbsp;<span style=\"color: #0000ff;\">\u63a2\u6e2c\u8ddd\u96e2\u7684\u539f\u7406\u5c31\u662f\u4f7f\u7528&nbsp;<span style=\"font-family: Times; font-size: 16px;\">Trig\u767c\u9001\u81f3\u5c1110&micro;S\u5bec\u5ea6\u7684\u8108\u6ce2&nbsp;<\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"font-size: 12pt; font-family: Times;\">\u767c\u5c04\u5f8c Echo\u6703\u7531\u4f4e\u96fb\u4f4d\u8b8a\u70ba\u9ad8\u96fb\u4f4d \u76f4\u5230\u63a5\u6536\u5230<\/span><span style=\"font-size: 12pt;\">\u53cd\u5c04\u56de\u4f86\u7684\u8d85\u97f3\u6ce2Echo\u7531\u9ad8\u96fb\u4f4d\u56de\u5fa9\u70ba\u4f4e\u96fb\u4f4d \u5176\u4e2d\u9593\u7684\u53cd\u61c9\u6642\u9593 \u85c9\u7531\u63db\u7b97 \u5f97\u5230\u6211\u5011\u53ef\u77e5\u7684 \u516c\u5206 \u548c \u82f1\u540b<\/span><\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\">\u63a5\u4e0b\u4f86\u662f\u7a0b\u5f0f\u78bc<\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<hr \/>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\"><span style=\"font-size: 12pt;\"><span style=\"color: #333333; font-family: Verdana, Arial, sans-serif; line-height: 16.8999996185303px;\">&nbsp;<\/span><\/span><\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>\/\/\u3000&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u65b0\u624b\u5be6\u4f5c\u3000\u8d85\u97f3\u6ce2\u61c9\u7528(HC-SR04) \u5012\u8eca\u96f7\u9054 by \u3000\u963f\u4fca\u3000\uff5e \/\/<br \/>#include &lt;Ultrasonic.h&gt; \/\/\u3000\u4f7f\u7528\u8d85\u97f3\u6ce2\u7684\u7a0b\u5f0f\u5eab<br \/>#define TRIGGER_PIN 12 \/\/\u3000\u5b9a\u7fa9\u6a21\u7d44triger\u7aef\u70ba\u6578\u4f4d\u63a5\u817312<br \/>#define ECHO_PIN 11 \/\/\u3000\u5b9a\u7fa9\u6a21\u7d44echo\u7aef\u70ba\u6578\u4f4d\u63a5\u817311<br \/>int spk=13; \/\/\u3000\u5b9a\u7fa9\u63da\u8072\u5668\u70ba\u6578\u4f4d\u63a5\u817313<br \/>Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN); \/\/\u8a2d\u5b9aHC-SR04\u521d\u59cb\u5316\u53c3\u6578<br \/>void setup()<br \/> {<br \/> Serial.begin(9600);<br \/> pinMode(spk, OUTPUT);<br \/> }<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>void loop()<br \/> {<br \/> float cmMsec; \/\/\u3000\u5b9a\u7fa9\u6d6e\u52d5\u6578<br \/> long microsec = ultrasonic.timing(); \/\/\u3000 \u6e2c\u8ddd\uff0c\u8fd4\u56de\u7684\u662f\u4e00\u500b\u6642\u9593\u55ae\u4f4d(microsec)<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>cmMsec = ultrasonic.convert(microsec,Ultrasonic::CM); \/\/\u5c07\u6e2c\u5f97\u7684\u6642\u9593\u55ae\u4f4d\u8a08\u7b97\u70ba\u8ddd\u96e2\u55ae\u4f4d<br \/> Serial.print(&#8221; CM: &#8220;);<br \/> Serial.println(cmMsec);<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p> if( cmMsec &gt;= 80 &amp;&amp; cmMsec &lt;= 100){ \/\/\u3000\u5047\u8a2d\u8ddd\u96e2\u4ecb\u65bc80~100\u4e4b\u9593<br \/> for(int i = 0; i &lt; 12000; i++) \/\/\u3000\u8ff4\u5708\u91cd\u8907<br \/> digitalWrite(spk, 0);<br \/> digitalWrite(spk, 1);<br \/> delay(300);<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>}<br \/> else if (cmMsec &gt;= 60 &amp;&amp; cmMsec &lt;= 79){ \/\/\u3000\u5047\u8a2d\u8ddd\u96e2\u4ecb\u65bc60~79\u4e4b\u9593<br \/> for(int i = 0; i &lt; 12000; i++) \/\/\u3000\u8ff4\u5708\u91cd\u8907<br \/> digitalWrite(spk, 1);<\/p>\n<p> digitalWrite(spk, 0);<br \/> delay(100);<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>}<br \/> else if (cmMsec &gt;= 40 &amp;&amp; cmMsec &lt;= 59){ \/\/\u3000\u5047\u8a2d\u8ddd\u96e2\u4ecb\u65bc40~59\u4e4b\u9593<br \/> for(int i = 0; i &lt; 12000; i++) \/\/\u3000\u8ff4\u5708\u91cd\u8907<br \/> digitalWrite(spk, 1);<\/p>\n<p> digitalWrite(spk, 0);<br \/> delay(50);<br \/> }<br \/> else if (cmMsec &gt;= 30 &amp;&amp; cmMsec &lt;= 39){ \/\/\u3000\u5047\u8a2d\u8ddd\u96e2\u4ecb\u65bc30~39\u4e4b\u9593<br \/> for(int i = 0; i &lt; 12000; i++) \/\/\u3000\u8ff4\u5708\u91cd\u8907<br \/> digitalWrite(spk, 1);<br \/> digitalWrite(spk, 0);<br \/> delay(20);<br \/> }<br \/> else if (cmMsec &gt;= 20 &amp;&amp; cmMsec &lt;= 29){ \/\/\u3000\u5047\u8a2d\u8ddd\u96e2\u4ecb\u65bc20~29\u4e4b\u9593 <br \/> for(int i = 0; i &lt; 6000; i++) \/\/\u3000\u8ff4\u5708\u91cd\u8907<br \/> digitalWrite(spk, 1);<\/p>\n<p> digitalWrite(spk, 0);<br \/> delay(10);<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>}<br \/> else if (cmMsec &lt;19){ \/\/\u3000\u5047\u8a2d\u8ddd\u96e2\u5c0f\u65bc19<\/p>\n<p> digitalWrite(spk, 1); <\/p>\n<p> delay(10);<\/p>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n<p>}<br \/> else<br \/> digitalWrite(spk, 0);&nbsp;<\/p>\n<p>}<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u9019\u662f\u6709\u8a31\u591a\u4f7f\u7528\u65b0\u7684\u8a9e\u6cd5 &nbsp;\u5176\u4e2d&nbsp;&nbsp;&amp;&amp; &nbsp;\u662f\u908f\u8f2f\u9598\u61c9\u7528\u8a9e\u6cd5 \u5176\u4e2d\u6709&nbsp;<\/span><span style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: 12pt; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;\"><span style=\"color: #ff6600;\">&amp;&amp; (\u908f\u8f2f\u4e0a\u7684 and)<\/span>&nbsp;<\/span><span style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: 12pt; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;\"><span style=\"color: #008000;\">|| (\u908f\u8f2f\u4e0a\u7684 or)<\/span>&nbsp;<\/span><span style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: 12pt; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;\">! (not)&nbsp;<span style=\"color: #000000;\">\u90a3\u53c8\u4ee3\u8868\u4ec0\u9ebc\u5462? \u6211\u9644\u4e0a\u9ad8\u4e2d\u6642\u7684\u7b46\u8a18~~<\/span><\/span><\/p>\n<p><span style=\"margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: 12pt; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;\"><span style=\"color: #000000;\"><a href=\"http:\/\/o4043380.pixnet.net\/album\/photo\/574486678\"><img title=\"\u908f\u8f2f\u9598\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1423043435-778036348_n.jpg\" alt=\"\u908f\u8f2f\u9598\" border=\"0\" \/><\/a> &nbsp;<\/span><\/span><\/p>\n<p><span style=\"font-size: 16px;\"><span style=\"color: #ff6600;\">And \u4ee3\u8868 \u5169\u4ef6\u4e8b\u70ba\u771f\u624d\u80fd\u901a<\/span> <span style=\"color: #008000;\">Or \u4ee3\u8868 \u53ea\u8981\u4e00\u4ef6\u4e8b\u70ba\u771f \u5c31\u53ef\u4ee5\u901a<\/span> <span style=\"color: #3366ff;\">Not \u53ea\u8981\u662f\u5047\u7684 \u5c31\u80fd\u901a&nbsp;<span style=\"color: #000000;\">\u6240\u4ee5 <span style=\"color: #ff6600;\">And<\/span>( cmMsec &gt;= 80 &amp;&amp; cmMsec &lt;= 100) \u7528\u610f\u5728\u65bc \u8b93\u4ed6\u6709\u4ecb\u65bc\u67d0\u6578\u548c\u67d0\u6578\u4e4b\u9593\u7684 \u5b9a\u7fa9\u57df<\/span><\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt; color: #000000;\">\u518d\u4f86\u662f for &nbsp;for\u662f\u8ff4\u5708\u7528\u7684\u8a9e\u6cd5 \u5f8c\u9762\u7528\u5230\u50cf(int i =0; i &lt;X; i++) &nbsp;X\u70ba\u4efb\u610f\u6578 ++\u70ba\u905e\u589e &nbsp;i=0 \u4e00\u76f4\u52a0\u5230\u4e0d\u8d85\u904eX \u5728X\u4e4b\u524d\u91cd\u8986\u57f7\u884c \u6211\u7528\u8ff4\u5708\u4e3b\u8981\u63a7\u5236 \u8702\u9cf4\u5668\u7684 \u97ff\u61c9\u983b\u7387 \u8b93\u4ed6\u6709\u6025\u4fc3\u7684\u611f\u89ba<\/span><\/p>\n<p><span style=\"font-size: 12pt; color: #000000;\">\u7e3d\u7d50<\/span><\/p>\n<p><span style=\"font-size: 16px;\">\u5229\u7528\u8d85\u97f3\u6ce2\u8b80\u53d6\u5230\u7684\u8ddd\u96e2 \u5728\u5229\u7528\u7a0b\u5f0f\u4e0a\u7684\u8b8a\u5316 \u4f86\u9054\u6210\u8702\u9cf4\u5668\u7684\u8b8a\u5316 \u8d8a\u8fd1\u8d8a\u6025\u7684\u611f\u89ba \u6c7d\u8eca\u7684\u5012\u8eca\u96f7\u9054 \u5176\u539f\u7406\u90fd\u4e00\u6a23 \u6211\u662f\u963f\u4fca \u8b1d\u8b1d\u5927\u5bb6~~<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3 style=\"margin: 30px 0px 15px; padding: 0px; border: 0px; font-family: 'Droid serif', Helvetica, Arial, sans-serif; font-size: 24px; font-weight: normal; font-stretch: inherit; line-height: 1.2; vertical-align: baseline; color: #111111;\">&nbsp;<\/h3>\n<p style=\"margin: 0.5em 0px; line-height: 22.3999996185303px; color: #252525; font-family: sans-serif; font-size: 14px;\">&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u597d \u6211\u662f\u963f\u4fca \u4e0a\u6b21\u5229\u7528\u7d05\u5916\u7dda\u7684\u7279\u6027 \u4f86\u9054\u6210\u5075\u6e2c\u7269\u9ad4\u7684\u611f\u61c9 \u9019\u6b21\u8981\u4f7f\u7528\u8d85\u97f3\u6ce2\u7684\u7279\u6027\u4f86\u9054\u6210\u5075\u6e2c\u7269\u9ad4\u548c\u4e4b\u9593\u7684\u8ddd\u96e2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts\/85"}],"collection":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":1,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":552,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions\/552"}],"wp:attachment":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}