http://lifestyle201.com/wiki/index.php?action=history&feed=atom&title=SKU%3ARB-02S041_%E5%A4%8F%E6%99%AEGP2D12%E7%BA%A2%E5%A4%96%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8 337p日本欧洲亚洲大胆张筱雨 ,欧美日韩精品视频免费观看,狂野少女免费完整版中文 2025-03-14T04:06:18Z 本wiki的該頁(yè)面的版本歷史 MediaWiki 1.21.2 http://lifestyle201.com/wiki/index.php?title=SKU:RB-02S041_%E5%A4%8F%E6%99%AEGP2D12%E7%BA%A2%E5%A4%96%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8&diff=8535&oldid=prev Zhangxin:/* 資料下載 */ 2021-12-09T09:12:58Z <p>?<span dir="auto"><span class="autocomment">資料下載</span></span></p> <table class='diff diff-contentalign-left'> <col class='diff-marker' /> <col class='diff-content' /> <col class='diff-marker' /> <col class='diff-content' /> <tr style='vertical-align: top;'> <td colspan='2' style="background-color: white; color:black; text-align: center;">←上一版本</td> <td colspan='2' style="background-color: white; color:black; text-align: center;">2021年12月9日 (四) 09:12的版本</td> </tr><tr><td colspan="2" class="diff-lineno">第152行:</td> <td colspan="2" class="diff-lineno">第152行:</td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無(wú)框|右]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無(wú)框|右]]</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品資料</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品資料</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>下載鏈接:https://pan.baidu.com/s/<del class="diffchange diffchange-inline">1wBgY5NlU7urm3oa8eGdPCw </del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>下載鏈接:https://pan.baidu.com/s/<ins class="diffchange diffchange-inline">1RMQU2yor5JgKd3zedkE8FQ </ins></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">提取碼:iew2&#160; &lt;br/&gt;</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">提取碼:uomr</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品購(gòu)買(mǎi)鏈接:http://lifestyle201.com/goods-181.html</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品購(gòu)買(mǎi)鏈接:http://lifestyle201.com/goods-181.html</div></td></tr> </table> Zhangxin http://lifestyle201.com/wiki/index.php?title=SKU:RB-02S041_%E5%A4%8F%E6%99%AEGP2D12%E7%BA%A2%E5%A4%96%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8&diff=8059&oldid=prev 2018年9月29日 (六) 05:56 Arduino77 2018-09-29T05:56:58Z <p></p> <table class='diff diff-contentalign-left'> <col class='diff-marker' /> <col class='diff-content' /> <col class='diff-marker' /> <col class='diff-content' /> <tr style='vertical-align: top;'> <td colspan='2' style="background-color: white; color:black; text-align: center;">←上一版本</td> <td colspan='2' style="background-color: white; color:black; text-align: center;">2018年9月29日 (六) 05:56的版本</td> </tr><tr><td colspan="2" class="diff-lineno">第11行:</td> <td colspan="2" class="diff-lineno">第11行:</td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># 模擬輸出噪聲:&lt;200mV &#160;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># 模擬輸出噪聲:&lt;200mV &#160;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># 測(cè)量距離與輸出模擬電壓關(guān)系:2.4V~0.4V模擬信號(hào)對(duì)應(yīng)10cm~80cm,輸出與距離成反比非線性關(guān)系</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div># 測(cè)量距離與輸出模擬電壓關(guān)系:2.4V~0.4V模擬信號(hào)對(duì)應(yīng)10cm~80cm,輸出與距離成反比非線性關(guān)系</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===</del>產(chǎn)品尺寸圖<del class="diffchange diffchange-inline">===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">9.</ins>產(chǎn)品尺寸圖<ins class="diffchange diffchange-inline">&lt;br/&gt;</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0411.jpg|700px|縮略圖|居中]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0411.jpg|700px|縮略圖|居中]]</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===</del>模擬信號(hào)與測(cè)量距離對(duì)應(yīng)表<del class="diffchange diffchange-inline">===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">10.</ins>模擬信號(hào)與測(cè)量距離對(duì)應(yīng)表<ins class="diffchange diffchange-inline">&lt;br/&gt;</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0412.jpg|700px|縮略圖|居中]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0412.jpg|700px|縮略圖|居中]]</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">上圖就是GP2D12紅外線測(cè)距傳感器的電壓值與距離值的關(guān)系曲線,從這個(gè)曲線可以看出,電壓輸出與距離成反比,而且是非線性關(guān)系。根據(jù)上圖關(guān)系曲線,大約關(guān)系為10cm距離時(shí)有2</del>.55V輸出,80cm距離時(shí)有0.<del class="diffchange diffchange-inline">42V輸出??梢酝ㄟ^(guò)該曲線擬合出電壓值與距離值的數(shù)學(xué)關(guān)系式,但是這個(gè)關(guān)系式里的距離是參考距離值,實(shí)際距離值</del>=(參考距離值-0.42)<del class="diffchange diffchange-inline">cm,另外由于Arduino的模擬量采樣命令analogRead</del>(),采樣的數(shù)據(jù)范圍是0至1023,對(duì)應(yīng)的電壓范圍是0至5V,每格數(shù)據(jù)代表0.<del class="diffchange diffchange-inline">0049V,于是讀取的有效數(shù)據(jù)應(yīng)該由86</del>(0.42V)至520(2.548V)。所以最終可以推導(dǎo)出實(shí)際距離與采樣數(shù)據(jù)之間的關(guān)系式為:&lt;br/&gt;</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">上圖是GP2D12紅外線測(cè)距傳感器的電壓值與距離值的關(guān)系曲線,從這個(gè)曲線可以看出,電壓輸出與距離成反比,而且是非線性關(guān)系。&lt;br/&gt;</ins></div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">根據(jù)上圖關(guān)系曲線,大約關(guān)系為10cm距離時(shí)有2</ins>.55V輸出,80cm距離時(shí)有0.<ins class="diffchange diffchange-inline">42V輸出。可以通過(guò)該曲線擬合出電壓值與距離值的數(shù)學(xué)關(guān)系式,但是這個(gè)關(guān)系式里的距離是參考距離值.&lt;br/&gt;</ins></div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">實(shí)際距離值</ins>=(參考距離值-0.42)<ins class="diffchange diffchange-inline">cm&lt;br/&gt;</ins></div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">另外由于Arduino的模擬量采樣命令analogRead</ins>(),采樣的數(shù)據(jù)范圍是0至1023,對(duì)應(yīng)的電壓范圍是0至5V,每格數(shù)據(jù)代表0.<ins class="diffchange diffchange-inline">0049V。&lt;br/&gt;</ins></div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">所以讀取的有效數(shù)據(jù)應(yīng)該由86</ins>(0.42V)至520(2.548V)。所以最終可以推導(dǎo)出實(shí)際距離與采樣數(shù)據(jù)之間的關(guān)系式為:&lt;br/&gt;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''&lt;big&gt;實(shí)際距離=2547.8/((float)采樣數(shù)據(jù)*0.49-10.41)-0.42&lt;/big&gt;'''&lt;br/&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''&lt;big&gt;實(shí)際距離=2547.8/((float)采樣數(shù)據(jù)*0.49-10.41)-0.42&lt;/big&gt;'''&lt;br/&gt;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===</del>信號(hào)輸出<del class="diffchange diffchange-inline">===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">11.</ins>信號(hào)輸出<ins class="diffchange diffchange-inline">&lt;br/&gt;</ins></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>ADC0831可以將模擬信號(hào)轉(zhuǎn)為數(shù)字信號(hào)輸出</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>ADC0831可以將模擬信號(hào)轉(zhuǎn)為數(shù)字信號(hào)輸出<ins class="diffchange diffchange-inline">&lt;br/&gt;</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0413.jpg|700px|縮略圖|居中]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0413.jpg|700px|縮略圖|居中]]</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">==</del>接口定義<del class="diffchange diffchange-inline">==</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">12.</ins>接口定義<ins class="diffchange diffchange-inline">&lt;br/&gt;</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Vo:輸出引腳</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Vo:輸出引腳</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* GND:電源地</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* GND:電源地</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Vcc:電源正極</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Vcc:電源正極</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">==使用方法==</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">=</del>==工作原理<del class="diffchange diffchange-inline">=</del>==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==工作原理==</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>通過(guò)紅外線的反射原理,從發(fā)射到接收到回傳信號(hào),傳感器共引出三個(gè)引腳分別接,信號(hào)線S、電源地G、電源正VCC,將信號(hào)線與 Arduino 板的 Analog IN 引腳相連接。通過(guò)對(duì)Arduino編程實(shí)現(xiàn)模擬量讀取,程序簡(jiǎn)短好用。</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>通過(guò)紅外線的反射原理,從發(fā)射到接收到回傳信號(hào),傳感器共引出三個(gè)引腳分別接,信號(hào)線S、電源地G、電源正VCC,將信號(hào)線與 Arduino 板的 Analog IN 引腳相連接。通過(guò)對(duì)Arduino編程實(shí)現(xiàn)模擬量讀取,程序簡(jiǎn)短好用。</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">=</del>==性能簡(jiǎn)評(píng)<del class="diffchange diffchange-inline">=</del>==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==性能簡(jiǎn)評(píng)==</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>GP2D12使用性能個(gè)人簡(jiǎn)評(píng):&lt;br/&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>GP2D12使用性能個(gè)人簡(jiǎn)評(píng):&lt;br/&gt;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>優(yōu)點(diǎn):&lt;br/&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>優(yōu)點(diǎn):&lt;br/&gt;</div></td></tr> <tr><td colspan="2" class="diff-lineno">第44行:</td> <td colspan="2" class="diff-lineno">第50行:</td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>總體來(lái)說(shuō):&lt;br/&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>總體來(lái)說(shuō):&lt;br/&gt;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* GP2d12在對(duì)測(cè)量精度要求不高,測(cè)量范圍在1m以?xún)?nèi)的情況下,對(duì)物體距離值的定位是非常簡(jiǎn)單有效地、操作簡(jiǎn)便、實(shí)用性強(qiáng)。</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* GP2d12在對(duì)測(cè)量精度要求不高,測(cè)量范圍在1m以?xún)?nèi)的情況下,對(duì)物體距離值的定位是非常簡(jiǎn)單有效地、操作簡(jiǎn)便、實(shí)用性強(qiáng)。</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>===<del class="diffchange diffchange-inline">接線方法</del>===</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">使用方法</ins>==</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">=example1_Arduino===</ins></div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 硬件連接</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>將傳感器連接到UNO控制器模擬口A1上,注意對(duì)應(yīng)線序:一般情況下3P線黃色接信號(hào),紅色接電源正,黑色接電源負(fù)</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>將傳感器連接到UNO控制器模擬口A1上,注意對(duì)應(yīng)線序:一般情況下3P線黃色接信號(hào),紅色接電源正,黑色接電源負(fù)</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===例子程序===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 示例程序</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&lt;pre style=&quot;color:blue&quot;&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&lt;pre style=&quot;color:blue&quot;&gt;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>#define pin A0</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>#define pin A0</div></td></tr> <tr><td colspan="2" class="diff-lineno">第72行:</td> <td colspan="2" class="diff-lineno">第82行:</td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>}</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>}</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&lt;/pre&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&lt;/pre&gt;</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===</del>程序效果<del class="diffchange diffchange-inline">===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* </ins>程序效果</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>打開(kāi) Arduino IDE 串口監(jiān)視器可以觀察到當(dāng)前傳感器測(cè)試到的距離。</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>打開(kāi) Arduino IDE 串口監(jiān)視器可以觀察到當(dāng)前傳感器測(cè)試到的距離。</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:02S04110.png|500px|有框|居中]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:02S04110.png|500px|有框|居中]]</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>===<del class="diffchange diffchange-inline">應(yīng)用例程</del>===</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">====連接示意圖====</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>===<ins class="diffchange diffchange-inline">example2_Arduino</ins>===</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 硬件連接</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0414.jpg|700px|縮略圖|居中]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:RB-02S0414.jpg|700px|縮略圖|居中]]</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>首先將距離傳感器固定到舵機(jī)上,可以使用熱熔膠或者膠帶。然后使用一個(gè)1uf電解電容和一個(gè)22uf電解電容并聯(lián)在5V穩(wěn)壓芯片L4940V5上。將紅外距離傳感器的信號(hào)線插入0號(hào)模擬引腳。4個(gè)LED通過(guò)1KΩ電阻插入3、5、6、11引腳。最后將舵機(jī)信號(hào)線接在9號(hào)引腳上。</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>首先將距離傳感器固定到舵機(jī)上,可以使用熱熔膠或者膠帶。然后使用一個(gè)1uf電解電容和一個(gè)22uf電解電容并聯(lián)在5V穩(wěn)壓芯片L4940V5上。將紅外距離傳感器的信號(hào)線插入0號(hào)模擬引腳。4個(gè)LED通過(guò)1KΩ電阻插入3、5、6、11引腳。最后將舵機(jī)信號(hào)線接在9號(hào)引腳上。</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">====例子程序====</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 示例程序</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&lt;pre style='color:blue'&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&lt;pre style='color:blue'&gt;</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>#include &lt;Servo.h&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>#include &lt;Servo.h&gt;</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> </del>const int SERVO&#160; =9;&#160; //伺服電機(jī)連接在9號(hào)引腳</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const int SERVO&#160; =9;&#160; //伺服電機(jī)連接在9號(hào)引腳</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> </del>const int IR&#160; &#160; =0;&#160; //紅外距離傳感器連接在0號(hào)模擬引腳</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const int IR&#160; &#160; =0;&#160; //紅外距離傳感器連接在0號(hào)模擬引腳</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> </del>const int LED1&#160; =3;&#160; //LED輸出1</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const int LED1&#160; =3;&#160; //LED輸出1</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> </del>const int LED2&#160; =5;&#160; //LED輸出2</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const int LED2&#160; =5;&#160; //LED輸出2</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> </del>const int LED3&#160; =6;&#160; //LED 輸出3</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const int LED3&#160; =6;&#160; //LED 輸出3</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> </del>const int LED4&#160; =11;&#160; //LED 輸出4</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const int LED4&#160; =11;&#160; //LED 輸出4</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Servo myServo;&#160; &#160; //伺服電機(jī)對(duì)象</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Servo myServo;&#160; &#160; //伺服電機(jī)對(duì)象</div></td></tr> <tr><td colspan="2" class="diff-lineno">第133行:</td> <td colspan="2" class="diff-lineno">第145行:</td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&#160;&#160; &#160; return dist;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //返回縮放后的距離</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>&#160;&#160; &#160; return dist;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //返回縮放后的距離</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>}&lt;/pre&gt;</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>}&lt;/pre&gt;</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">====</del>程序效果<del class="diffchange diffchange-inline">====</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&#160;</div></td></tr> <tr><td colspan="2">&#160;</td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* </ins>程序效果</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>當(dāng)舵機(jī)轉(zhuǎn)動(dòng)到一個(gè)給定的位置時(shí)測(cè)定距離,將其轉(zhuǎn)換為L(zhǎng)ED的亮度值,改變LED的亮度值,將其轉(zhuǎn)向下一個(gè)位置,然后繼續(xù),如此重復(fù)。</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>當(dāng)舵機(jī)轉(zhuǎn)動(dòng)到一個(gè)給定的位置時(shí)測(cè)定距離,將其轉(zhuǎn)換為L(zhǎng)ED的亮度值,改變LED的亮度值,將其轉(zhuǎn)向下一個(gè)位置,然后繼續(xù),如此重復(fù)。</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr> </table> Arduino77 http://lifestyle201.com/wiki/index.php?title=SKU:RB-02S041_%E5%A4%8F%E6%99%AEGP2D12%E7%BA%A2%E5%A4%96%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8&diff=8058&oldid=prev Arduino77:/* 產(chǎn)品相關(guān)推薦 */ 2018-09-29T05:50:56Z <p>?<span dir="auto"><span class="autocomment">產(chǎn)品相關(guān)推薦</span></span></p> <table class='diff diff-contentalign-left'> <col class='diff-marker' /> <col class='diff-content' /> <col class='diff-marker' /> <col class='diff-content' /> <tr style='vertical-align: top;'> <td colspan='2' style="background-color: white; color:black; text-align: center;">←上一版本</td> <td colspan='2' style="background-color: white; color:black; text-align: center;">2018年9月29日 (六) 05:50的版本</td> </tr><tr><td colspan="2" class="diff-lineno">第136行:</td> <td colspan="2" class="diff-lineno">第136行:</td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>當(dāng)舵機(jī)轉(zhuǎn)動(dòng)到一個(gè)給定的位置時(shí)測(cè)定距離,將其轉(zhuǎn)換為L(zhǎng)ED的亮度值,改變LED的亮度值,將其轉(zhuǎn)向下一個(gè)位置,然后繼續(xù),如此重復(fù)。</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>當(dāng)舵機(jī)轉(zhuǎn)動(dòng)到一個(gè)給定的位置時(shí)測(cè)定距離,將其轉(zhuǎn)換為L(zhǎng)ED的亮度值,改變LED的亮度值,將其轉(zhuǎn)向下一個(gè)位置,然后繼續(xù),如此重復(fù)。</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>==<del class="diffchange diffchange-inline">產(chǎn)品相關(guān)推薦</del>==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">資料下載</ins>==</div></td></tr> <tr><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無(wú)框|右]]</div></td><td class='diff-marker'>&#160;</td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無(wú)框|右]]</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===產(chǎn)品購(gòu)買(mǎi)地址===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 產(chǎn)品資料</ins></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http</del>://<del class="diffchange diffchange-inline">www</del>.<del class="diffchange diffchange-inline">alsrobot</del>.<del class="diffchange diffchange-inline">cn</del>/<del class="diffchange diffchange-inline">goods-181.html 夏普GP2D12紅外測(cè)距傳感器]</del>&lt;br/&gt;</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">下載鏈接:https</ins>://<ins class="diffchange diffchange-inline">pan</ins>.<ins class="diffchange diffchange-inline">baidu</ins>.<ins class="diffchange diffchange-inline">com</ins>/<ins class="diffchange diffchange-inline">s/1wBgY5NlU7urm3oa8eGdPCw </ins></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===周邊產(chǎn)品推薦===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">提取碼:iew2&#160; </ins>&lt;br/&gt;</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http</del>://lifestyle201.com/goods-<del class="diffchange diffchange-inline">183</del>.html <del class="diffchange diffchange-inline">Arduino IR Sensor GP2Y0A02YK0F夏普紅外測(cè)距傳感器]&lt;br/&gt;</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 產(chǎn)品購(gòu)買(mǎi)鏈接:http</ins>://lifestyle201.com/goods-<ins class="diffchange diffchange-inline">181</ins>.html</div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===相關(guān)問(wèn)題解答===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://www.makerspace.cn/forum.php?mod=viewthread&amp;tid=3851&amp;highlight=%E5%A4%8F%E6%99%AE 夏普紅外測(cè)距邊界問(wèn)題]&lt;br/&gt;</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===相關(guān)學(xué)習(xí)資料===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr> <tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://www.makerspace.cn/portal.php 奧松機(jī)器人技術(shù)論壇]&lt;br/&gt;</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr> </table> Arduino77 http://lifestyle201.com/wiki/index.php?title=SKU:RB-02S041_%E5%A4%8F%E6%99%AEGP2D12%E7%BA%A2%E5%A4%96%E6%B5%8B%E8%B7%9D%E4%BC%A0%E6%84%9F%E5%99%A8&diff=5967&oldid=prev Arduino77:以“右 ==產(chǎn)品概述== GP2D12 IR Sensor 是日本夏普公司推出的一款性?xún)r(jià)比高、最常用的紅外測(cè)距傳感器...”為內(nèi)容創(chuàng)建頁(yè)面 2016-06-22T06:39:45Z <p>以“<a href="/wiki/index.php/%E6%96%87%E4%BB%B6:RB-02S041.jpg" title="文件:RB-02S041.jpg">右</a> ==產(chǎn)品概述== GP2D12 IR Sensor 是日本夏普公司推出的一款性?xún)r(jià)比高、最常用的紅外測(cè)距傳感器...”為內(nèi)容創(chuàng)建頁(yè)面</p> <p><b>新頁(yè)面</b></p><div>[[文件:RB-02S041.jpg|500px|縮略圖|右]]<br /> ==產(chǎn)品概述==<br /> GP2D12 IR Sensor 是日本夏普公司推出的一款性?xún)r(jià)比高、最常用的紅外測(cè)距傳感器、其可用來(lái)對(duì)物體的距離進(jìn)行測(cè)量,實(shí)現(xiàn)輪式機(jī)器人的避障功能。它不但體積小、功耗低、價(jià)格便宜,而且測(cè)距效果好,適合廣大機(jī)器人發(fā)燒友使用。<br /> ==規(guī)格參數(shù)==<br /> # 測(cè)量射程范圍:10 to 80 cm <br /> # 最大允許角度:&gt;40° <br /> # 電源電壓:4.5 to 5.5V <br /> # 平均功耗:35mA <br /> # 峰值功耗:約200mA <br /> # 更新頻率/周期:25Hz / 40ms <br /> # 模擬輸出噪聲:&lt;200mV <br /> # 測(cè)量距離與輸出模擬電壓關(guān)系:2.4V~0.4V模擬信號(hào)對(duì)應(yīng)10cm~80cm,輸出與距離成反比非線性關(guān)系<br /> ===產(chǎn)品尺寸圖===<br /> [[文件:RB-02S0411.jpg|700px|縮略圖|居中]]<br /> ===模擬信號(hào)與測(cè)量距離對(duì)應(yīng)表===<br /> [[文件:RB-02S0412.jpg|700px|縮略圖|居中]]<br /> 上圖就是GP2D12紅外線測(cè)距傳感器的電壓值與距離值的關(guān)系曲線,從這個(gè)曲線可以看出,電壓輸出與距離成反比,而且是非線性關(guān)系。根據(jù)上圖關(guān)系曲線,大約關(guān)系為10cm距離時(shí)有2.55V輸出,80cm距離時(shí)有0.42V輸出??梢酝ㄟ^(guò)該曲線擬合出電壓值與距離值的數(shù)學(xué)關(guān)系式,但是這個(gè)關(guān)系式里的距離是參考距離值,實(shí)際距離值=(參考距離值-0.42)cm,另外由于Arduino的模擬量采樣命令analogRead(),采樣的數(shù)據(jù)范圍是0至1023,對(duì)應(yīng)的電壓范圍是0至5V,每格數(shù)據(jù)代表0.0049V,于是讀取的有效數(shù)據(jù)應(yīng)該由86(0.42V)至520(2.548V)。所以最終可以推導(dǎo)出實(shí)際距離與采樣數(shù)據(jù)之間的關(guān)系式為:&lt;br/&gt;<br /> '''&lt;big&gt;實(shí)際距離=2547.8/((float)采樣數(shù)據(jù)*0.49-10.41)-0.42&lt;/big&gt;'''&lt;br/&gt;<br /> <br /> ===信號(hào)輸出===<br /> ADC0831可以將模擬信號(hào)轉(zhuǎn)為數(shù)字信號(hào)輸出<br /> [[文件:RB-02S0413.jpg|700px|縮略圖|居中]]<br /> ==接口定義==<br /> * Vo:輸出引腳<br /> * GND:電源地<br /> * Vcc:電源正極<br /> ==使用方法==<br /> ===工作原理===<br /> 通過(guò)紅外線的反射原理,從發(fā)射到接收到回傳信號(hào),傳感器共引出三個(gè)引腳分別接,信號(hào)線S、電源地G、電源正VCC,將信號(hào)線與 Arduino 板的 Analog IN 引腳相連接。通過(guò)對(duì)Arduino編程實(shí)現(xiàn)模擬量讀取,程序簡(jiǎn)短好用。<br /> ===性能簡(jiǎn)評(píng)===<br /> GP2D12使用性能個(gè)人簡(jiǎn)評(píng):&lt;br/&gt;<br /> 優(yōu)點(diǎn):&lt;br/&gt;<br /> * 紅外傳感器連接使用簡(jiǎn)單,對(duì)于1米以?xún)?nèi)的中距離測(cè)試精度良好、性能優(yōu)越。<br /> * 數(shù)據(jù)測(cè)量值穩(wěn)定,測(cè)量結(jié)果波動(dòng)較小。<br /> * 數(shù)據(jù)傳輸穩(wěn)定,程序讀取簡(jiǎn)單不會(huì)在數(shù)據(jù)傳輸過(guò)程中出現(xiàn)卡死的現(xiàn)象,錯(cuò)誤信號(hào)較少。<br /> 缺陷:&lt;br/&gt;<br /> * GP2d12測(cè)量范圍有限,最大值80cm,并且從60cm開(kāi)外的距離開(kāi)始測(cè)量值的波動(dòng)較大,與實(shí)際情況偏差增大。(60cm為室內(nèi)環(huán)境的個(gè)人感受,不同環(huán)境所產(chǎn)生的干擾不同所以可能達(dá)到的精度也有所不同。)<br /> * 當(dāng)障礙物(或目標(biāo))與紅外傳感器之間的距離小于10cm時(shí),測(cè)量值將與實(shí)際值出現(xiàn)明顯偏差,當(dāng)距離值從10降至0的過(guò)程中,測(cè)量值將在10~35之間遞增。(電壓值與距離值關(guān)系:如圖)<br /> * 紅外傳感器,使用時(shí)會(huì)受到環(huán)境光的影響,在室內(nèi)使用時(shí),傳感器數(shù)據(jù)接收時(shí)可能會(huì)受到白熾燈光線的印象,產(chǎn)生一些非真的距離值。<br /> GP2D12使用注意及使用優(yōu)化方式:&lt;br/&gt;<br /> * 當(dāng)多個(gè)GP2d12同時(shí)連接Arduino板使用時(shí),由于供電量的增加,可能造成電壓不穩(wěn)定而對(duì)測(cè)量結(jié)果產(chǎn)生偏差。從硬件角度可以通過(guò)在VCC與 GND之間接電容的方式來(lái)穩(wěn)定對(duì)GP2d12的供電,減少供電電壓波動(dòng)對(duì)測(cè)量結(jié)果的影響,或者在GND與數(shù)據(jù)線之間接一個(gè)電容減小輸出電壓的波動(dòng)略去可能出現(xiàn)的誤差信號(hào),提高數(shù)據(jù)穩(wěn)定性。(接線見(jiàn)附錄圖)<br /> * 針對(duì)測(cè)量時(shí)可能產(chǎn)生的干擾和誤差數(shù)值,可能從軟件的角度進(jìn)行改進(jìn)和防止,通過(guò)多次的測(cè)量記錄,排除一場(chǎng)輸入量后,取均值來(lái)的到一個(gè)較為穩(wěn)定更為接近實(shí)際值的測(cè)量數(shù)據(jù)。其次可以根據(jù)實(shí)際的使用要求,可以進(jìn)行有效值的范圍定義,過(guò)濾超出范圍的測(cè)量結(jié)果,該范圍可根據(jù)使用情況自行界定。<br /> * 針對(duì)紅外傳感器測(cè)量時(shí),可能受環(huán)境光影響測(cè)量結(jié)果,在安放使用時(shí)竟可能避免傳感器正對(duì)燈光的使用,可以將 GP2d12的發(fā)射接收端水平放置進(jìn)行測(cè)量,盡可能減少環(huán)境光帶來(lái)的干擾。<br /> 總體來(lái)說(shuō):&lt;br/&gt;<br /> * GP2d12在對(duì)測(cè)量精度要求不高,測(cè)量范圍在1m以?xún)?nèi)的情況下,對(duì)物體距離值的定位是非常簡(jiǎn)單有效地、操作簡(jiǎn)便、實(shí)用性強(qiáng)。<br /> ===接線方法===<br /> 將傳感器連接到UNO控制器模擬口A1上,注意對(duì)應(yīng)線序:一般情況下3P線黃色接信號(hào),紅色接電源正,黑色接電源負(fù)<br /> ===例子程序===<br /> &lt;pre style=&quot;color:blue&quot;&gt;<br /> #define pin A0<br /> void setup () <br /> {<br /> Serial.begin (9600);<br /> pinMode (pin, INPUT);<br /> }<br /> void loop () <br /> {<br /> uint16_t value = analogRead (pin);<br /> uint16_t range = get_gp2d12 (value);<br /> Serial.println (value);<br /> Serial.print (range);<br /> Serial.println (&quot; mm&quot;);<br /> Serial.println ();<br /> delay (500);<br /> }<br /> <br /> //return distance (mm)<br /> uint16_t get_gp2d12 (uint16_t value) {<br /> if (value &lt; 30)<br /> value = 30;<br /> return ((67870.0 / (value - 3.0)) - 40.0);<br /> }<br /> &lt;/pre&gt;<br /> ===程序效果===<br /> 打開(kāi) Arduino IDE 串口監(jiān)視器可以觀察到當(dāng)前傳感器測(cè)試到的距離。<br /> [[文件:02S04110.png|500px|有框|居中]]<br /> ===應(yīng)用例程===<br /> ====連接示意圖====<br /> [[文件:RB-02S0414.jpg|700px|縮略圖|居中]]<br /> 首先將距離傳感器固定到舵機(jī)上,可以使用熱熔膠或者膠帶。然后使用一個(gè)1uf電解電容和一個(gè)22uf電解電容并聯(lián)在5V穩(wěn)壓芯片L4940V5上。將紅外距離傳感器的信號(hào)線插入0號(hào)模擬引腳。4個(gè)LED通過(guò)1KΩ電阻插入3、5、6、11引腳。最后將舵機(jī)信號(hào)線接在9號(hào)引腳上。<br /> ====例子程序====<br /> &lt;pre style='color:blue'&gt;<br /> #include &lt;Servo.h&gt;<br /> const int SERVO =9; //伺服電機(jī)連接在9號(hào)引腳<br /> const int IR =0; //紅外距離傳感器連接在0號(hào)模擬引腳<br /> const int LED1 =3; //LED輸出1<br /> const int LED2 =5; //LED輸出2<br /> const int LED3 =6; //LED 輸出3<br /> const int LED4 =11; //LED 輸出4<br /> <br /> Servo myServo; //伺服電機(jī)對(duì)象<br /> int dist1 = 0; //第一象限距離<br /> int dist2 = 0; //第二象限距離<br /> int dist3 = 0; //第三象限距離<br /> int dist4 = 0; //第四象限距離<br /> <br /> void setup()<br /> {<br /> myServo.attach(SERVO); //綁定伺服電機(jī)<br /> pinMode(LED1, OUTPUT); //將LED設(shè)置為輸出<br /> pinMode(LED2, OUTPUT); //將LED設(shè)置為輸出<br /> pinMode(LED3, OUTPUT); //將LED設(shè)置為輸出<br /> pinMode(LED4, OUTPUT); //將LED設(shè)置為輸出<br /> }<br /> <br /> void loop()<br /> {<br /> //將伺服電機(jī)在4個(gè)區(qū)域中掃描并改變LED亮度<br /> dist1 = readDistance(15); //在15°處進(jìn)行紅外測(cè)距<br /> analogWrite(LED1, dist1); //調(diào)節(jié)LED亮度<br /> delay(300); //下次測(cè)量前的延時(shí)<br /> <br /> dist2 = readDistance(65); //在65°處進(jìn)行紅外測(cè)距<br /> analogWrite(LED2, dist2); //調(diào)節(jié)LED亮度<br /> delay(300); //下次測(cè)量前的延時(shí)<br /> <br /> dist3 = readDistance(115); //在115°處進(jìn)行紅外測(cè)距<br /> analogWrite(LED3, dist3); //調(diào)節(jié)LED亮度<br /> delay(300); //下次測(cè)量前的延時(shí)<br /> <br /> dist4 = readDistance(165); //在165°處進(jìn)行紅外測(cè)距<br /> analogWrite(LED4, dist4); //調(diào)節(jié)LED亮度<br /> delay(300); //下次測(cè)量前的延時(shí)<br /> }<br /> <br /> int readDistance(int pos)<br /> {<br /> myServo.write(pos); //轉(zhuǎn)動(dòng)到指定位置<br /> delay(600); //等待伺服電機(jī)轉(zhuǎn)動(dòng)<br /> int dist = analogRead(IR); //讀取紅外傳感器<br /> dist = map(dist, 50, 500, 0, 255); //轉(zhuǎn)換到LED的范圍內(nèi) <br /> dist = constrain(dist, 0, 255); //約束它<br /> return dist; //返回縮放后的距離<br /> }&lt;/pre&gt;<br /> ====程序效果====<br /> 當(dāng)舵機(jī)轉(zhuǎn)動(dòng)到一個(gè)給定的位置時(shí)測(cè)定距離,將其轉(zhuǎn)換為L(zhǎng)ED的亮度值,改變LED的亮度值,將其轉(zhuǎn)向下一個(gè)位置,然后繼續(xù),如此重復(fù)。<br /> <br /> ==產(chǎn)品相關(guān)推薦==<br /> [[文件:erweima.png|230px|無(wú)框|右]]<br /> ===產(chǎn)品購(gòu)買(mǎi)地址===<br /> [http://lifestyle201.com/goods-181.html 夏普GP2D12紅外測(cè)距傳感器]&lt;br/&gt;<br /> ===周邊產(chǎn)品推薦===<br /> [http://lifestyle201.com/goods-183.html Arduino IR Sensor GP2Y0A02YK0F夏普紅外測(cè)距傳感器]&lt;br/&gt;<br /> ===相關(guān)問(wèn)題解答===<br /> [http://www.makerspace.cn/forum.php?mod=viewthread&amp;tid=3851&amp;highlight=%E5%A4%8F%E6%99%AE 夏普紅外測(cè)距邊界問(wèn)題]&lt;br/&gt;<br /> ===相關(guān)學(xué)習(xí)資料===<br /> [http://www.makerspace.cn/portal.php 奧松機(jī)器人技術(shù)論壇]&lt;br/&gt;</div> Arduino77