tag:blogger.com,1999:blog-92075237695534226912024-03-05T20:34:21.997+08:00Dennis Lab一起來做開放硬體運動: 創客(Hacker & Maker) sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.comBlogger68125tag:blogger.com,1999:blog-9207523769553422691.post-53409562596953384862016-05-31T14:22:00.000+08:002016-05-31T14:28:29.165+08:00更新 Motoduino WiFi Terminal (ESP8266) 韌體 步驟(Update Firmware)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span style="font-family: 標楷體; font-size: 18.0pt; mso-bidi-font-family: Tahoma; mso-font-kerning: 0pt;">刷新<span lang="EN-US"> Motoduino WiFi Terminal </span>韌體
步驟如下<span lang="EN-US"> :<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6YX4V_q4z5kF2l1ysQyGiKDse_RSFsdTot9_opBHA47Tyb2Jmv8959oPli-ZL37Q-Q7xgyQQOLlA7YY8whahp12q_9Ert9gC9DWag_QNHqqh0f1HmfeYKQk9pTnXmHbvkaPFY89XpRsJQ/s1600/esp8266_v2_guide.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6YX4V_q4z5kF2l1ysQyGiKDse_RSFsdTot9_opBHA47Tyb2Jmv8959oPli-ZL37Q-Q7xgyQQOLlA7YY8whahp12q_9Ert9gC9DWag_QNHqqh0f1HmfeYKQk9pTnXmHbvkaPFY89XpRsJQ/s1600/esp8266_v2_guide.jpg" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f">
<v:stroke joinstyle="miter">
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0">
<v:f eqn="sum @0 1 0">
<v:f eqn="sum 0 0 @1">
<v:f eqn="prod @2 1 2">
<v:f eqn="prod @3 21600 pixelWidth">
<v:f eqn="prod @3 21600 pixelHeight">
<v:f eqn="sum @0 0 1">
<v:f eqn="prod @6 1 2">
<v:f eqn="prod @7 21600 pixelWidth">
<v:f eqn="sum @8 21600 0">
<v:f eqn="prod @7 21600 pixelHeight">
<v:f eqn="sum @10 21600 0">
</v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas>
<v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f">
<o:lock aspectratio="t" v:ext="edit">
</o:lock></v:path></v:stroke></v:shapetype><v:shape id="圖片_x0020_20" o:spid="_x0000_i1033" style="height: 311.25pt; mso-wrap-style: square; visibility: visible; width: 415.5pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image001.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span style="color: #333333; font-size: 16.0pt;">使用材料<span lang="EN-US">:<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span style="color: #333333; font-size: 16.0pt;"><span lang="EN-US"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l1 level1 lfo2; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-size: 16.0pt;">1.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span lang="EN-US" style="color: #333333; font-size: 16.0pt;">Micro USB </span><span style="color: #333333; font-size: 16.0pt;">線<span lang="EN-US"> x 1<o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l1 level1 lfo2; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-size: 16.0pt;">2.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span lang="EN-US" style="color: #333333; font-size: 16.0pt;">USB TO TTL </span><span style="color: #333333; font-size: 16.0pt;">轉接線<span lang="EN-US"> x 1<o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l1 level1 lfo2; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-size: 16.0pt;">3.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span lang="EN-US" style="color: #333333; font-size: 16.0pt;">RJ11</span><span style="color: #333333; font-size: 16.0pt;">轉<span lang="EN-US">4pin</span>杜邦線<span lang="EN-US">
x 1<o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l1 level1 lfo2; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-size: 18.0pt;">4.</span><!--[endif]--><span style="color: #333333; font-size: 16.0pt;">軟體功具
<span lang="EN-US"><a href="http://www.motoduino.com/download-english/category/10-wifi-terminal-esp8266/">ESP DOWNLOAD TOOL V2.4</a></span></span><span lang="EN-US" style="color: #333333; font-size: 18.0pt;"> </span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l1 level1 lfo2; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9MnjIEopz_jLbHlvhvDe9PBto-UFdpB6KFZ-KyzDMPonwvLe7Psz4xuVS_70mBD2fScLJ7z68gV1WANUnfRNjYm2YhmsSJDYfSWHNEpYz1v0c8pQ2gjqUP3eHmUqqbvzSKMVrvCeTId5D/s1600/flash_FW_material.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9MnjIEopz_jLbHlvhvDe9PBto-UFdpB6KFZ-KyzDMPonwvLe7Psz4xuVS_70mBD2fScLJ7z68gV1WANUnfRNjYm2YhmsSJDYfSWHNEpYz1v0c8pQ2gjqUP3eHmUqqbvzSKMVrvCeTId5D/s320/flash_FW_material.jpg" width="240" /></a></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l1 level1 lfo2; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;"><br /></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt;">
<br /></div>
<div class="MsoListParagraph" style="line-height: 11.85pt; margin-left: 18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_1" o:spid="_x0000_i1032" style="height: 285.75pt; mso-wrap-style: square; rotation: 90; visibility: visible; width: 381pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image002.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span style="color: #333333; font-size: 16.0pt;">大致上步驟<span lang="EN-US">:<o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-size: 14.0pt;">1.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-size: 14.0pt;">硬體接線如下圖<span lang="EN-US">:<o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt;">
<span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">黑色接 <span lang="EN-US">GND </span>黃色接 <span lang="EN-US">TX </span>綠色接<span lang="EN-US"> RX<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_8" o:spid="_x0000_i1031" style="height: 298.5pt; mso-wrap-style: square; visibility: visible; width: 398.25pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image003.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKHsMhxo76aFiij_QIgdrolekQXZOWlGfey6IcgH62XcdyqOJV2t6zUxPdcKBx5KAliUVuV7WWO-gkjR_p16liEo__CFtZd4cZpR9e8S869hR5soWiDVGE-L-TmCzdgZjWzMYg1ro5dZjs/s1600/Flash_FW_connection.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKHsMhxo76aFiij_QIgdrolekQXZOWlGfey6IcgH62XcdyqOJV2t6zUxPdcKBx5KAliUVuV7WWO-gkjR_p16liEo__CFtZd4cZpR9e8S869hR5soWiDVGE-L-TmCzdgZjWzMYg1ro5dZjs/s320/Flash_FW_connection.jpg" width="320" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-size: 9pt; line-height: 11.85pt; text-indent: -18pt;"> </span><span style="font-size: 9pt; line-height: 11.85pt; text-indent: -18pt;"> </span><br />
<br />
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: 標楷體;">2.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;"> </span></span><!--[endif]--><span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">設定<span lang="EN-US">WiFi </span>模組為<span lang="EN-US">PRG </span>模式<span lang="EN-US">(</span>燒錄韌體模式<span lang="EN-US">)</span>。把<span lang="EN-US">UCB TO TTL</span>接到<span lang="EN-US">PC</span>,然後<span lang="EN-US">WiFi</span>模組開關撥到<span lang="EN-US">PRG</span>位置,如下圖<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_9" o:spid="_x0000_i1030" style="height: 291pt; mso-wrap-style: square; visibility: visible; width: 388.5pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image004.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVm3G5uO6lg-E-JluVh8x3AZUf0E0_lr4FbmGok01MKADP4aJrjNLTono4-J-HrkipFz7jPKMF12smx0XluSOQPNLh7LwEMLAnE6oq39Ayo14WAHZTOAYNJrtI5eDnZZOwEl4Rtgu-nRCH/s1600/flash_Ready.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVm3G5uO6lg-E-JluVh8x3AZUf0E0_lr4FbmGok01MKADP4aJrjNLTono4-J-HrkipFz7jPKMF12smx0XluSOQPNLh7LwEMLAnE6oq39Ayo14WAHZTOAYNJrtI5eDnZZOwEl4Rtgu-nRCH/s320/flash_Ready.jpg" width="240" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"> </span><span style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9pt; line-height: 11.85pt;"> </span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: 標楷體;">3.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;"> </span></span><!--[endif]--><span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">開啟<span lang="EN-US">FLASH TOOL (ESP_DOWNLOAD_TOOL_V2.4.exe)</span>,設定如下面畫面<span lang="EN-US">!<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_11" o:spid="_x0000_i1029" style="height: 360.75pt; mso-wrap-style: square; visibility: visible; width: 414.75pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image005.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-W8IW3lkQjTL1Qm_rhlrThAN8IyaviNN-mBse7C3ihjtbhwVQOOwPC10fNXz94mDpdxEXnV0A1wQAte5EMA4fyH6LoMAZ4E8jOeu3WaojmCsec-upsaEEQ6dbxUfuwCr8WOB6DNyPX-KH/s1600/ESP_TOOL_DOWNLOAD_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-W8IW3lkQjTL1Qm_rhlrThAN8IyaviNN-mBse7C3ihjtbhwVQOOwPC10fNXz94mDpdxEXnV0A1wQAte5EMA4fyH6LoMAZ4E8jOeu3WaojmCsec-upsaEEQ6dbxUfuwCr8WOB6DNyPX-KH/s320/ESP_TOOL_DOWNLOAD_1.jpg" width="320" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"> </span><span style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9pt; line-height: 11.85pt;"> </span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: 標楷體;">4.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;"> </span></span><!--[endif]--><span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">燒錄韌體成功畫面如下<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_16" o:spid="_x0000_i1028" style="height: 311.25pt; mso-wrap-style: square; visibility: visible; width: 415.5pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image006.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8yktpTPvOGGLY3B854UbFDzol6NaX8adJ_Tfb2P1bvGY7dKFfUkZNSedbdC-XnS3rw9QrMYXZwLDiqpH4imJMUtPB_Cc353b3XsXRkrNzHxXRDrWak_lWcs8Vkv7Sh9scr7R8SF70Kwhs/s1600/Flash_OK.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8yktpTPvOGGLY3B854UbFDzol6NaX8adJ_Tfb2P1bvGY7dKFfUkZNSedbdC-XnS3rw9QrMYXZwLDiqpH4imJMUtPB_Cc353b3XsXRkrNzHxXRDrWak_lWcs8Vkv7Sh9scr7R8SF70Kwhs/s320/Flash_OK.jpg" width="320" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"> </span><span style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9pt; line-height: 11.85pt;"> </span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: 標楷體;">5.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;"> </span></span><!--[endif]--><span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">關閉 <span lang="EN-US">FLASH TOOL </span>燒錄功具<span lang="EN-US">, </span>開啟<span lang="EN-US">Arduino
IDE </span>的<span lang="EN-US">Serial Monitor, </span>且設定如下圖<span lang="EN-US">!<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_17" o:spid="_x0000_i1027" style="height: 489pt; mso-wrap-style: square; visibility: visible; width: 407.25pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image007.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLE2f7h706PMyjRErIMsyLwTxYcNtLeLRqt9C9Zn2YpsnR9to-f2dL-Qm6zdoBpLBuLMqjVn-U0dmjAK8mWWsrSrLkMmtteYZqta_E9AkAnagvflUXGLf06VHyNzo30d1mKxUhFgt20-Cl/s1600/SerialMonitor_Setting.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLE2f7h706PMyjRErIMsyLwTxYcNtLeLRqt9C9Zn2YpsnR9to-f2dL-Qm6zdoBpLBuLMqjVn-U0dmjAK8mWWsrSrLkMmtteYZqta_E9AkAnagvflUXGLf06VHyNzo30d1mKxUhFgt20-Cl/s320/SerialMonitor_Setting.jpg" width="266" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: 標楷體;">6.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;"> </span></span><!--[endif]--><span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">修改 <span lang="EN-US">baud rate</span>為<span lang="EN-US"> 9600 <o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_18" o:spid="_x0000_i1026" style="height: 490.5pt; mso-wrap-style: square; visibility: visible; width: 408pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image008.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0NUpcybC-L-nPXEAluV7e4ys7qrZLPnDKswcxukpFnzhMcrqgjN0Y5NIgBsWeI_Apx7vkMhlG_S_gtdiaNYKlOTXfwd5uHm-o5r089R3LQapvISzXhLIBSSBdbodpsXQpmmY8XrCK785l/s1600/AT_UART_Setting.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0NUpcybC-L-nPXEAluV7e4ys7qrZLPnDKswcxukpFnzhMcrqgjN0Y5NIgBsWeI_Apx7vkMhlG_S_gtdiaNYKlOTXfwd5uHm-o5r089R3LQapvISzXhLIBSSBdbodpsXQpmmY8XrCK785l/s320/AT_UART_Setting.jpg" width="266" /></a></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-line-height-alt: 11.85pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: #333333; font-family: 標楷體; mso-bidi-font-family: 標楷體;">7.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;"> </span></span><!--[endif]--><span style="color: #333333; font-family: 標楷體; mso-bidi-font-family: Tahoma;">檢查是否修改成功,修改<span lang="EN-US">Serial Monitor </span>的<span lang="EN-US"> baud rate</span>為<span lang="EN-US"> 9600, </span>然後輸入<span lang="EN-US"> AT </span>命令<span lang="EN-US">, </span>如回應<span lang="EN-US"> OK, </span>表示修改成功<span lang="EN-US">! </span>接下來就可以接到<span lang="EN-US">Arduino </span>板子上使用<span lang="EN-US">!<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 11.85pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><v:shape id="圖片_x0020_19" o:spid="_x0000_i1025" style="height: 396.75pt; mso-wrap-style: square; visibility: visible; width: 415.5pt;" type="#_x0000_t75">
<v:imagedata o:title="" src="file:///C:\Users\CQ61\AppData\Local\Temp\msohtmlclip1\01\clip_image009.jpg">
</v:imagedata></v:shape></span><span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHQfdbgcpC5MGP9yS0NAwlaU0cNe4-EK6_s05-4LAIVrz4vwmqd5eQCutqqCxbaqzqhfwPjQV2V_OYHriD7TvrwkuclqmWWGfUdaVPpYNARRazJe4U4jeJzDgqlF1yjYrmNqvsjiwJ7e91/s1600/ArduinoSerialESP8266.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="306" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHQfdbgcpC5MGP9yS0NAwlaU0cNe4-EK6_s05-4LAIVrz4vwmqd5eQCutqqCxbaqzqhfwPjQV2V_OYHriD7TvrwkuclqmWWGfUdaVPpYNARRazJe4U4jeJzDgqlF1yjYrmNqvsjiwJ7e91/s320/ArduinoSerialESP8266.jpg" width="320" /></a></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><br /></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><br /></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;">前往 <a href="http://www.motoduino.com/">Motoduino </a></span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;">FB: Motoduino Taiwan</span></div>
<div class="MsoNormal" style="line-height: 11.85pt; margin-left: 18.0pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-pagination: widow-orphan; text-indent: -18.0pt;">
<span lang="EN-US" style="color: #333333; font-family: "tahoma" , sans-serif; font-size: 9.0pt;"><br /></span></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com4tag:blogger.com,1999:blog-9207523769553422691.post-75844875338531763802016-02-19T18:39:00.001+08:002016-02-19T18:39:23.598+08:00AT Commands sending to ESP8266 from Arduino IDE Serial<div dir="ltr" style="text-align: left;" trbidi="on">
This is a Arduino sketch for AT Commands sending from Arduino Serial(TxRx) to ESP8266.<br />
When AT commands is received by arduino, they will bypass arduino to ESP8266!<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOIHOZVbEWGF8OQswtgpXRIxQhmqEG9IppmCdUBwelhMJL1MPR76xaz2I3R5cho_5U3ivjA_QB2dYfaYmUJI_bBYz9NKqQyGH0pTn0EFh8veyFgHKzmGNpLhpgUWthKwNS3EBbWd4I-ccy/s1600/ArduinoSerialESP8266.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="306" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOIHOZVbEWGF8OQswtgpXRIxQhmqEG9IppmCdUBwelhMJL1MPR76xaz2I3R5cho_5U3ivjA_QB2dYfaYmUJI_bBYz9NKqQyGH0pTn0EFh8veyFgHKzmGNpLhpgUWthKwNS3EBbWd4I-ccy/s320/ArduinoSerialESP8266.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Connection examples: Motoduino <a href="http://www.motoduino.com/" target="_blank">WiFi Module(ESP8266)</a> with <a href="http://www.motoduino.com/component/content/article/?layout=edit&id=44" target="_blank">S4A IO Board</a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUZEmW5OFCcKwEgLZRs7ASj4bb4RTFRqzj_nu0hq_vghDsYrRJT-r8JnVb-I_uFt7w-hqT20g9ar-ADfW5NS6HGDoxp3HW1G7QDl2GaiUOSElgIB8na5pPjE4fPq31yfp3LkZQpBTNzuw1/s1600/ArduinoSerialESP8266_connections.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUZEmW5OFCcKwEgLZRs7ASj4bb4RTFRqzj_nu0hq_vghDsYrRJT-r8JnVb-I_uFt7w-hqT20g9ar-ADfW5NS6HGDoxp3HW1G7QDl2GaiUOSElgIB8na5pPjE4fPq31yfp3LkZQpBTNzuw1/s320/ArduinoSerialESP8266_connections.jpg" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Connections example: ESP-12<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMl378BUiT2c-12Zi_inSqa3S-jls-SfMF2KAkxsphSbNnkEumuiWfve3cdEk7c29_inAj6xgpcMOpU8HMfu1w1qBUxXvtl0htbmqe6I6d4CPqaEqjkvkfQXsic-V8u_iKh3edhMU9tHom/s1600/uno_esp8266.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMl378BUiT2c-12Zi_inSqa3S-jls-SfMF2KAkxsphSbNnkEumuiWfve3cdEk7c29_inAj6xgpcMOpU8HMfu1w1qBUxXvtl0htbmqe6I6d4CPqaEqjkvkfQXsic-V8u_iKh3edhMU9tHom/s320/uno_esp8266.jpg" width="320" /></a></div>
<br />
<br />
Copy and paste the following sketch to Arduino IDE! Enjoy!<br />
<br />
///////////////////////////////////////////////////////////////////////////////////////////////////////////////<br />
#include <SoftwareSerial.h><br />
SoftwareSerial esp8266(3,2); // use pins (3,2) for software serial S4A IO board<br />
// Rx : D3, Tx: D2<br />
#define DEBUG true<br />
#define BUFFER_SIZE 512<br />
char serBuffer[BUFFER_SIZE];<br />
char command[128];<br />
<br />
void setup() {<br />
<br />
Serial.begin(9600); // start serial communication at 9600bps<br />
esp8266.begin(9600); // Modify it for your esp8266 module<br />
<br />
Serial.println("Ready...");<br />
}<br />
<br />
void loop() {<br />
char ser_char;<br />
<br />
if(Serial.available()>0){<br />
Serial.readBytesUntil('\n', serBuffer, BUFFER_SIZE);<br />
int len = strlen(serBuffer);<br />
<br />
if(3 == len)<br />
{<br />
serBuffer[len]='\n';<br />
if(!strncmp(serBuffer, "AT\r\n",4))<br />
sendData(serBuffer, 1000, DEBUG);<br />
}<br />
else if(( len > 3)&&(serBuffer[2]=='+'))<br />
{<br />
Serial.readBytesUntil('\n', serBuffer, BUFFER_SIZE);<br />
len = strlen(serBuffer);<br />
serBuffer[len]='\n';<br />
//Serial.println(serBuffer); <br />
sendData(serBuffer, 2000, DEBUG);<br />
}<br />
clearBuffer();<br />
}<br />
}<br />
<br />
String sendData(String command, const int timeout, boolean debug)<br />
{<br />
String response = "";<br />
<br />
esp8266.print(command); // send the read character to the esp8266<br />
long int time = millis();<br />
while( (time+timeout) > millis())<br />
{<br />
while(esp8266.available())<br />
{ <br />
// The esp has data so display its output to the serial window<br />
char c = esp8266.read(); // read the next character.<br />
response+=c;<br />
} <br />
}<br />
if(DEBUG){<br />
Serial.print(response);<br />
}<br />
return response;<br />
}<br />
<br />
void clearBuffer(void) {<br />
for (int i =0;i<BUFFER_SIZE;i++ ) {<br />
serBuffer[i]=0;<br />
}<br />
}<br />
<div>
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-15357220577681245992016-02-05T17:38:00.000+08:002016-02-21T22:30:36.430+08:00Motoduino WiFi Terminal Esp8266(ESP-12) <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
"硬"式要它更簡單!<br />
今天要來介紹新設計的無線模組Motoduino WiFi Terminal(下圖), 此模組主要元件為 ESP8266(ESP-12). 其實用法與原始模組ESP8266一樣! 不過在此設計就是希望接線簡單化配合Motoduino 一些模組應用更方便!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9ffEux_jAHCVdOin3Z5-EPn2_yKorBZm5yvNRxu291rCuF9RLp_63oBR4rzAquF4ph9-DPPYV7-ypzPyfVqvNXG9uDLBk8RshivrPKlR2aTa81F1RynDjL4TASeYXrHtJpUTJuaJySIeU/s1600/WiFi_Terminal_Pin.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9ffEux_jAHCVdOin3Z5-EPn2_yKorBZm5yvNRxu291rCuF9RLp_63oBR4rzAquF4ph9-DPPYV7-ypzPyfVqvNXG9uDLBk8RshivrPKlR2aTa81F1RynDjL4TASeYXrHtJpUTJuaJySIeU/s320/WiFi_Terminal_Pin.jpg" width="320" /></a></div>
<br />
主要有兩種方式可以使用此WiFi Terminal.<br />
<br />
一. 結合Arduino使用<br />
透過<a href="http://www.motoduino.com/component/content/article/?layout=edit&id=44" target="_blank">S4A IO</a>/<a href="http://www.motoduino.com/component/content/article/?layout=edit&id=40" target="_blank">Sensor Board</a> 的RJ11孔位可以很方便連接Arduino開發板,下圖是配合 S4A IO Board 製作遙控車(<a href="http://www.motoduino.com/component/content/article/?layout=edit&id=78" target="_blank">Motoduino </a>U1 + <a href="http://www.motoduino.com/component/content/article/?layout=edit&id=44" target="_blank">S4A IO Board</a> + WiFi Teminal)! 因為ESP8266可以是AP及Station Mode,所以使用上更方便! (此範例使用Software Serial方式)<br />
通常ESP8266有時需要較大的電流安培數(約200mA),往往Arduino本身提供的5V電源不太足夠,尤其如果再加上一些感測元件上去使得板子電流耗損更大,也因此常常聽到使用者談到穩定性問題!大部分原因來自於電源穩定性(在實驗時或從ESP8266官網了解)! 所以此模組提供一個Micro USB的外部電源接頭, 當Arduino提供電流不足給WiFi Terminal時可以利用外部電源! 此Terminal有提供開關可以電源切換!<br />
<br />
<br />
<a href="https://youtu.be/Coo2I4p3D-Q" target="_blank">Youtube 影片</a>!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ShTsE9aC1MHEDARnvSHKCzenjW-1xoWcBgiq3givn9gF3XUVh-faQw9y829kd5N3fT-iPoKpP1KCh9bhNUdgbwvK-46DO8EUc22ziAR1DHtVI3Zj7nSMegUHIgJ2X7dnbKeXfq4uN_bh/s1600/WiFi_Terminal_U1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ShTsE9aC1MHEDARnvSHKCzenjW-1xoWcBgiq3givn9gF3XUVh-faQw9y829kd5N3fT-iPoKpP1KCh9bhNUdgbwvK-46DO8EUc22ziAR1DHtVI3Zj7nSMegUHIgJ2X7dnbKeXfq4uN_bh/s320/WiFi_Terminal_U1.jpg" width="320" /></a></div>
<br />
<br />
二. WiFi Terminal 單獨運行(如下圖)!<br />
ESP8266本來就可以獨立運行(Standalone mode), 此WiFi Terminal模組可以利用RJ11接頭接上USB-Serial 傳輸線即可以對WiFi Terminal作programming! (如下圖).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAtnJAAAbsl1vm6bOFZDQg32_zZwvPSs8TjxQ6ALpwe2mJi7NqQjcPhg_EkuwucMITxwxW4mqkdEjDVELkMORJwXoMgK8UJZ8ZJCCb9bhTrVNj0ZAO6fyXj6G6n40Z4UbLGUw1bI_lLw8z/s1600/WiFi_Update_FW..jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAtnJAAAbsl1vm6bOFZDQg32_zZwvPSs8TjxQ6ALpwe2mJi7NqQjcPhg_EkuwucMITxwxW4mqkdEjDVELkMORJwXoMgK8UJZ8ZJCCb9bhTrVNj0ZAO6fyXj6G6n40Z4UbLGUw1bI_lLw8z/s320/WiFi_Update_FW..jpg" width="320" /></a></div>
<br />
<br />
如果只是作個單一控制應用, 也可以利用RJ11接頭接上Motoduino一些Terminal如(Led, Relay, button, 等模組), 如下圖!<br />
<br />
<a href="https://youtu.be/leI0MJ__w0o" target="_blank">Youtube 影片</a>!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKoZ85R1izK4VtEFR7MUksaBhjZNNqDdwBm-hz-GlSYrFK3C8IRRZcaGbctOMl_UQ9Rfcn-ErqBgPecxYgxF6EYVhoHYXobJgWNPjH02w4AX9j11HsjSUVdjzahjxWfykGVxxHxJUV2NNJ/s1600/WiFi_Standalone_led.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKoZ85R1izK4VtEFR7MUksaBhjZNNqDdwBm-hz-GlSYrFK3C8IRRZcaGbctOMl_UQ9Rfcn-ErqBgPecxYgxF6EYVhoHYXobJgWNPjH02w4AX9j11HsjSUVdjzahjxWfykGVxxHxJUV2NNJ/s320/WiFi_Standalone_led.jpg" width="240" /></a></div>
<br />
如果有更複雜的應用,也可以把兩邊擴充的腳位焊上排針插在麵包板上延伸利用! 另外對Arduino 開發者來說, ESP8266也提供Library給Arduino 使用者, 透過簡單API及範例可以縮短開發時程!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNEbeZPO8p386_QT-9m-pHIWydg4TRzb_dIqtGfBCwGPHRbMFyMuLbr9BIPIwNzv_iqrEqJXBZh3wWJg-kBUjxkvO1SvnIQeozLnYHld6e_8wrn8rR8Y4dtuBDjovAiOMATbQgVVqlcjEE/s1600/WiFi_Bread.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNEbeZPO8p386_QT-9m-pHIWydg4TRzb_dIqtGfBCwGPHRbMFyMuLbr9BIPIwNzv_iqrEqJXBZh3wWJg-kBUjxkvO1SvnIQeozLnYHld6e_8wrn8rR8Y4dtuBDjovAiOMATbQgVVqlcjEE/s320/WiFi_Bread.jpg" width="320" /></a></div>
<br />
<br />
<br />
<a href="http://www.motoduino.com/">http://www.motoduino.com</a><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-39308110221378714212015-12-15T12:51:00.001+08:002015-12-15T12:51:29.312+08:00Kozig LED I2C介面的七段顯示器(另一版): 修改I2C Address <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div>
此次來說明 Kozig I2C LED 七段顯示器 另一版 如何修改 I2C Address!</div>
<div>
此版本出貨時 default I2C address 為 0x51, 可以利用Arduino 的 I2C scan address 找出!</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHGrhKiPW83OqEtv1EY_FeBaIJ0F0V5MNAXuF8rcLPmwHWnYXTSBA3IfE2FoWWHyaU3iy9kYwVmOwirhxDTl8IYsna_jFaP7HJOrUfKr7lOk6gMQO3m_b8-xCfOdFAy1-lYJvxlU3GxuGK/s1600/I2C_LED_New1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHGrhKiPW83OqEtv1EY_FeBaIJ0F0V5MNAXuF8rcLPmwHWnYXTSBA3IfE2FoWWHyaU3iy9kYwVmOwirhxDTl8IYsna_jFaP7HJOrUfKr7lOk6gMQO3m_b8-xCfOdFAy1-lYJvxlU3GxuGK/s320/I2C_LED_New1.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfwH0TxzQUZCZSIA2BTQNaHgvFnn6FdqUUrWyk9KXClbVnVnAF9j3gycbv8q0EjAljJvEsWwtosC69sasjXNFezRDIZROuXS4MTI-ieHnqEaBeLMVyHt0mdJDFUoZlyvH-AHoXRe7SL4Iz/s1600/I2C_LED_New.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="174" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfwH0TxzQUZCZSIA2BTQNaHgvFnn6FdqUUrWyk9KXClbVnVnAF9j3gycbv8q0EjAljJvEsWwtosC69sasjXNFezRDIZROuXS4MTI-ieHnqEaBeLMVyHt0mdJDFUoZlyvH-AHoXRe7SL4Iz/s320/I2C_LED_New.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEWLTCAWUB9kYQdVStiZAT5UbbZivHcc6AldJ4M87LHvY12pm4kL_PFygWLKb3X7gU4XMAsdrxpizIRQVl81-oOOVTSAWlV6_-42rTqQgcQ0-L4hXPd-4tEnPiahToE0fWjkOexdirommb/s1600/Kozig_i2c_led.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEWLTCAWUB9kYQdVStiZAT5UbbZivHcc6AldJ4M87LHvY12pm4kL_PFygWLKb3X7gU4XMAsdrxpizIRQVl81-oOOVTSAWlV6_-42rTqQgcQ0-L4hXPd-4tEnPiahToE0fWjkOexdirommb/s320/Kozig_i2c_led.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
修改步驟與前一版相同! 但是有兩點要注意:</div>
<div>
1. I2C Address 設定不一樣,例如 default 0x51 要改成 0x27則</div>
<div>
程式內要寫成</div>
<div>
<br /></div>
<div>
#define ZTSEG8B4_ADDR (0x27<<1) // 0x4E // 0100111xB </div>
<div>
<br /></div>
<div>
詳細可以看Ztlib library內範例 SEG8B4A036A_SetAddress</div>
<div>
<br /></div>
<div>
2. 因為有些I2C command不一樣, 所以Arduino Ztlib library也不一樣!</div>
<div>
下載處(<a href="http://www.motoduino.com/download-english/category/3-arduino-sketch/" target="_blank">LED _CA_ version</a>) </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;">步驟如下:</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;">1.斷電情況下將SCL接到GND, SDA接A4.</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;">2.接通電源,顯示 _CA_ 時,表示進入設定新地址模式.</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;">3.再將原來SCL接GND改接到A5.</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;">4.執行 SEG8B4A036A_SetAddress, (ztlib example)結束時會顯示新位置.</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;"> 例如新位置為 0x27 則顯示 _4E_</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;">5. 移除電源,LED 模組已改成新位址!</span></div>
<div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdT426UUMPxTot7otUB6IYRjCdRh3NC0oc5SoMw9o2W98bqfUhfZ6jxua_hNqgAqaE6mika82cK5rKRDOm3h-KlizOZ28MXkdD924jwP0l7dvxrMZpLI8Bg9cyp56ybLhNuCC8wmUFlJ4a/s1600/LED_SettingMode.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdT426UUMPxTot7otUB6IYRjCdRh3NC0oc5SoMw9o2W98bqfUhfZ6jxua_hNqgAqaE6mika82cK5rKRDOm3h-KlizOZ28MXkdD924jwP0l7dvxrMZpLI8Bg9cyp56ybLhNuCC8wmUFlJ4a/s320/LED_SettingMode.jpg" width="320" /></a></div>
<div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;"><br /></span></div>
<div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;"><br /></span></div>
<div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;"><br /></span></div>
<div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px; line-height: 20.79px;"><br /></span></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-60597063305193465232015-10-21T12:37:00.002+08:002015-10-21T12:40:15.270+08:00LED Web Controls by Intel Edison with I2C LCD1602<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
I2C devices 加到Intel Edison 其實很簡單,做法與arduino相同, 接上I2C device到 Edison Arduino後(藉由 S4A IO Board容易連接,請接到A4A5 位置),可以試著檢查系統是不是有偵測到裝置,command如 " i2cdetect -y -r 6 " , 直此命令後可以看到裝置的 I2C address. 注意的是Intel Edison 的 I2C bus是在 bus 6(Different to Raspberry Pi).<br />
<br />
此實驗LCD顯示 Edison IP address, 然後User透過WIFI在瀏覽器上控制LED ON/OFF.<br />
<br />
使用材料(<a href="http://class.ruten.com.tw/user/index00.php?s=sinocgt">Materials</a>):<br />
1. Intel Edison + Arduino Breakout Kit<br />
2. S4A IO Board<br />
3. I2C LCD1602<br />
4. LED Terminal<br />
<br />
首先, 把所有東西都接上去, 如下圖 , LCD1602接到 IO Board的 A4A5 位置, LED Terminal接到 D2D3 孔位.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrdbcJgjtRjlLjYsR-cRSEjajVhP9SUYRApTCjoiP_uOZUp1-5yjSVaCm2vM5dwozcGiK2IdzUhAm8UFC6oW2vbLOKyYBfnfTQ7MpoTkxOOjnVDRWXMju39G65wKInmkLw2YTy2jsZdp-u/s1600/Edison_I2CLCD.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrdbcJgjtRjlLjYsR-cRSEjajVhP9SUYRApTCjoiP_uOZUp1-5yjSVaCm2vM5dwozcGiK2IdzUhAm8UFC6oW2vbLOKyYBfnfTQ7MpoTkxOOjnVDRWXMju39G65wKInmkLw2YTy2jsZdp-u/s320/Edison_I2CLCD.jpg" width="320" /></a></div>
<br />
1. 進入 Edison board system, 然後輸入 如下圖.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgug0dgJWNm7CDc_rrfPQBg48nb2SkHUeIlKFBYBXY8jOFfkODs0NwP4nftcvSmvK__835Uo_DfCxzSoC3ckmR02XwbxNbTEDDi4OBft2zM0OUE9FraukU4RzXw9Lzp1kqtK_6PRlVi-so4/s1600/i2cdetect.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgug0dgJWNm7CDc_rrfPQBg48nb2SkHUeIlKFBYBXY8jOFfkODs0NwP4nftcvSmvK__835Uo_DfCxzSoC3ckmR02XwbxNbTEDDi4OBft2zM0OUE9FraukU4RzXw9Lzp1kqtK_6PRlVi-so4/s320/i2cdetect.jpg" width="320" /></a></div>
<br />
LCD1602的 I2C address is 0x27<br />
<br />
2. Open Arduino IDE, copy the below sketch and paste it to Arduino IDE.<br />
<br />
#include <SPI.h><br />
#include <WiFi.h><br />
#include <Wire.h><br />
#include <LiquidCrystal_I2C.h><br />
<br />
char ssid[] = "xxxxxxx"; // your network SSID (name)<br />
char pass[] = "xxxxxxx"; // your network password<br />
int keyIndex = 0; // your network key Index number (needed only for WEP)<br />
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display<br />
<br />
int status = WL_IDLE_STATUS;<br />
WiFiServer server(8080);<br />
<br />
void setup() {<br />
Serial.begin(9600); // initialize serial communication<br />
pinMode(2, OUTPUT); // set the LED pin mode<br />
<br />
lcd.init(); // initialize the lcd<br />
// Print a message to the LCD.<br />
lcd.backlight();<br />
<br />
lcd.print("Connecting...");<br />
<br />
// check for the presence of the shield:<br />
if (WiFi.status() == WL_NO_SHIELD) {<br />
Serial.println("WiFi shield not present");<br />
while(true); // don't continue<br />
}<br />
<br />
String fv = WiFi.firmwareVersion();<br />
if( fv != "1.1.0" )<br />
Serial.println("Please upgrade the firmware");<br />
<br />
// attempt to connect to Wifi network:<br />
while ( status != WL_CONNECTED) {<br />
Serial.print("Attempting to connect to Network named: ");<br />
Serial.println(ssid); // print the network name (SSID);<br />
<br />
// Connect to WPA/WPA2 network. Change this line if using open or WEP network: <br />
status = WiFi.begin(ssid, pass);<br />
// wait 10 seconds for connection:<br />
delay(10000);<br />
}<br />
server.begin(); // start the web server on port 80<br />
printWifiStatus(); // you're connected now, so print out the status<br />
}<br />
<br />
<br />
void loop() {<br />
WiFiClient client = server.available(); // listen for incoming clients<br />
<br />
if (client) { // if you get a client,<br />
Serial.println("new client"); // print a message out the serial port<br />
String currentLine = ""; // make a String to hold incoming data from the client<br />
while (client.connected()) { // loop while the client's connected<br />
if (client.available()) { // if there's bytes to read from the client,<br />
char c = client.read(); // read a byte, then<br />
Serial.write(c); // print it out the serial monitor<br />
if (c == '\n') { // if the byte is a newline character<br />
<br />
// if the current line is blank, you got two newline characters in a row.<br />
// that's the end of the client HTTP request, so send a response:<br />
if (currentLine.length() == 0) { <br />
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)<br />
// and a content-type so the client knows what's coming, then a blank line: <br />
client.println("HTTP/1.1 200 OK");<br />
client.println("Content-type:text/html");<br />
client.println();<br />
<br />
// the content of the HTTP response follows the header:<br />
client.print("Click <a href=\"/H\">here</a> turn the LED on pin 9 on<br>");<br />
client.print("Click <a href=\"/L\">here</a> turn the LED on pin 9 off<br>");<br />
<br />
// The HTTP response ends with another blank line:<br />
client.println();<br />
// break out of the while loop:<br />
break; <br />
}<br />
else { // if you got a newline, then clear currentLine:<br />
currentLine = "";<br />
}<br />
} <br />
else if (c != '\r') { // if you got anything else but a carriage return character,<br />
currentLine += c; // add it to the end of the currentLine<br />
}<br />
<br />
// Check to see if the client request was "GET /H" or "GET /L":<br />
if (currentLine.endsWith("GET /H")) {<br />
digitalWrite(2, HIGH); // GET /H turns the LED on<br />
Serial.println("LED ON");<br />
}<br />
if (currentLine.endsWith("GET /L")) {<br />
digitalWrite(2, LOW); // GET /L turns the LED off<br />
Serial.println("LED OFF");<br />
<br />
}<br />
}<br />
}<br />
// close the connection:<br />
client.stop();<br />
Serial.println("client disonnected");<br />
}<br />
}<br />
<br />
void printWifiStatus() {<br />
// print the SSID of the network you're attached to:<br />
Serial.print("SSID: ");<br />
Serial.println(WiFi.SSID());<br />
<br />
// print your WiFi shield's IP address:<br />
IPAddress ip = WiFi.localIP();<br />
Serial.print("IP Address: ");<br />
Serial.println(ip);<br />
<br />
// print the received signal strength:<br />
long rssi = WiFi.RSSI();<br />
Serial.print("signal strength (RSSI):");<br />
Serial.print(rssi);<br />
Serial.println(" dBm");<br />
// print where to go in a browser:<br />
Serial.print("To see this page in action, open a browser to http://");<br />
Serial.println(ip);<br />
<br />
lcd.clear();<br />
lcd.print(ip);<br />
<br />
}<br />
<br />
然後自行修改 ssid 和 pass 參數符合自己的 Router. (請自行下載 LiquidCrystal_I2C library)<br />
<br />
3. Upload sketch to Edison. 等幾十秒鐘LCD會顯示 IP address.<br />
4. 開啟PC瀏覽器輸入IP address and port 8080, 例如 http://192.168.1.28:8080<br />
<br />
請參考影片!<br />
<br />
https://youtu.be/vfpTnySBfiw<br />
<br />
<br />
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com1tag:blogger.com,1999:blog-9207523769553422691.post-58708832754126375632015-03-25T17:45:00.005+08:002015-03-25T17:45:49.485+08:00利用 Motoduino 修改 HC-06 藍牙模組名稱 (Change bluetooth 2.0 name)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">通常在市面上買來的HC-06藍牙模組 名稱大都是 linvor 或 HC-05, 這次來說明利用motoduino來修改模組名稱(其實跟修改baud rate方法一樣,只是AT Command不同)</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">在 </span><a href="http://motoduino.com/" style="background-color: white; color: #6699cc; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px; text-decoration: none;" target="_blank">Motoduino</a><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">上修改藍芽模組Baud Rate很簡單 步驟如下:</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;" /><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">範例說明是以藍牙HC-06傳輸速率Baud Rate為 57600 bps例子</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">1.打開 Arduino IDE 輸入底下程式(下圗)</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje8yXW4_06N2HvZ6emojDpin0o0xV-XQBrYbmrcUSzgRqc3mlmHs_T6F9NOn40offkdHqpTOECz0MQb_IIhd_PuhNkRif1Ttml4NFha2o2-7TjuHF_9kQUOfqvQ_xYJ6Anmphu0hu7cjIT/s1600/BT_change_name_sketch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje8yXW4_06N2HvZ6emojDpin0o0xV-XQBrYbmrcUSzgRqc3mlmHs_T6F9NOn40offkdHqpTOECz0MQb_IIhd_PuhNkRif1Ttml4NFha2o2-7TjuHF_9kQUOfqvQ_xYJ6Anmphu0hu7cjIT/s1600/BT_change_name_sketch.png" height="320" width="284" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">2.把Motoduino接上PC</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;" /><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">3.Compile程式然後upload到板子.</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;" /><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">4.等upload完後,移開motoduino跟PC連線,插上藍芽模組(如下圗).</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrvkDJY8BJceUCYaWwJlx7XXg3_sNlDXu34hA5du7xXlQe_0hiqOQzZC8AeSq8Rz4amUTTikh8Z3_NCoij1PvCVcAvWDSJWuw_MjBdS2825L1sNBDHj1Ryds9ahTsJ8MSzBKGfg5HebyAm/s1600/MotoduinoBThtml1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrvkDJY8BJceUCYaWwJlx7XXg3_sNlDXu34hA5du7xXlQe_0hiqOQzZC8AeSq8Rz4amUTTikh8Z3_NCoij1PvCVcAvWDSJWuw_MjBdS2825L1sNBDHj1Ryds9ahTsJ8MSzBKGfg5HebyAm/s1600/MotoduinoBThtml1.JPG" height="287" width="320" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">5. </span><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">把Motoduino再接上PC, 然後開啟Arduino的Serial Monitor如下圖注意右下角的baud rate欄位選成57600</span><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">bps, Serial Monitor內會顯示AT+NAMEMotoduinoOKsetname (如下圗), 此時藍芽模組名稱已改成Motoduino.</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip21kwEzeUdauG3bRktBP5bg_jdmqqKIVBwrdHanyfziTvCvCw3FzhyphenhyphenpQYcTEXrmdY69OCGnEkPoTNmxyyX_G_8wrtUUDdQyVt64GYAzUfKoBsY288L411ux_EcSqWRzSVfHM7y6V-Lo0u/s1600/BT_change_name.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip21kwEzeUdauG3bRktBP5bg_jdmqqKIVBwrdHanyfziTvCvCw3FzhyphenhyphenpQYcTEXrmdY69OCGnEkPoTNmxyyX_G_8wrtUUDdQyVt64GYAzUfKoBsY288L411ux_EcSqWRzSVfHM7y6V-Lo0u/s1600/BT_change_name.png" height="311" width="320" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">6. 可以用android手機連線試試!</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;">ps. 修改藍牙模組 baud rate 請參考<a href="http://sinocgtchen.blogspot.tw/2011/12/motoduino-baud-rate.html" target="_blank">這裡</a> </span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.8500003814697px; line-height: 20.7900009155273px;"><br /></span></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com3tag:blogger.com,1999:blog-9207523769553422691.post-59031346708655760712014-11-16T20:49:00.001+08:002014-11-16T20:49:42.209+08:00Arduino NFC/RFID = Arduino UNO + NFC Reader (PN532)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
NFC/RFID 實驗在Arduino 上其實也很簡單, 這次利用PN532相容板來做實驗, 此塊板子支援 I2C 和 SPI介面, 我就來用 SPI 跟Arduino連接! 參考下圖:<br />
<br />
Arduino PN532<br />
D10 ------> SS<br />
D11 ------> MOSI<br />
D12 ------> MISO<br />
D13 ------> SCK<br />
5V -------> 5V<br />
GND ------> GND<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqEZOrPVA2wqKRics1w0NpHagx58bQuv_LwxcTRrBVKdMIXPJOqa74_fNjuTEQ4W6kQI1npT7TneO3xm7-0OEj_mROdUJlSjU4mBnpJy7gjvvTofQKtbfsg-mIQnVqLW6-ocVFpK97CMFV/s1600/PN532_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqEZOrPVA2wqKRics1w0NpHagx58bQuv_LwxcTRrBVKdMIXPJOqa74_fNjuTEQ4W6kQI1npT7TneO3xm7-0OEj_mROdUJlSjU4mBnpJy7gjvvTofQKtbfsg-mIQnVqLW6-ocVFpK97CMFV/s1600/PN532_1.jpg" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnU080S9XliVnOmleOO4AHAmONd7SC_DGcdb82SF2kJxntzQyZ-YDNhp5z9jNX-2Ja0dm29N-U8B4_uXDH810ccfMvDJZFBvt3GzyvXODyVLQJ0Si6q04omo1e4wGjXLoqalcHRJWnuqo5/s1600/PN532_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnU080S9XliVnOmleOO4AHAmONd7SC_DGcdb82SF2kJxntzQyZ-YDNhp5z9jNX-2Ja0dm29N-U8B4_uXDH810ccfMvDJZFBvt3GzyvXODyVLQJ0Si6q04omo1e4wGjXLoqalcHRJWnuqo5/s1600/PN532_2.jpg" height="239" width="320" /></a></div>
<br />
<br />
Sketch 範例程式:<br />
<br />
#include <arduino.h><br />
#include <PN532.h><br />
<br />
#define SCK 13<br />
#define MOSI 11<br />
#define SS 10<br />
#define MISO 12<br />
<br />
PN532 nfc(SCK, MISO, MOSI, SS);<br />
<br />
void setup(void) {<br />
Serial.begin(9600);<br />
Serial.println("Hello!");<br />
<br />
nfc.begin();<br />
<br />
uint32_t versiondata = nfc.getFirmwareVersion();<br />
if (! versiondata) {<br />
Serial.print("Didn't find PN53x board");<br />
while (1); // halt<br />
}<br />
// Got ok data, print it out!<br />
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);<br />
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);<br />
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);<br />
Serial.print("Supports "); Serial.println(versiondata & 0xFF, HEX);<br />
<br />
// configure board to read RFID tags and cards<br />
nfc.SAMConfig();<br />
}<br />
<br />
<br />
void loop(void) {<br />
uint32_t id;<br />
// look for MiFare type cards<br />
id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);<br />
<br />
if (id != 0) {<br />
Serial.print("Read card #"); Serial.println(id);<br />
}<br />
}<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
PN532 arduino library 下載點 <a href="https://github.com/Seeed-Studio/PN532" target="_blank">here</a>.</div>
<div>
<br /></div>
<div>
很簡單! 拿起 NFC tag 感應一下就會跑出 Card id.</div>
<div>
<br /></div>
<div>
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com9tag:blogger.com,1999:blog-9207523769553422691.post-58660777009423439182014-10-28T12:03:00.000+08:002017-04-16T19:34:43.492+08:00傳統伺服馬達(Servo) 改造成 可回饋位置伺服馬達(Smart Servo) Servo Hacked!<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
幾個月前買了幾顆二手伺服馬達 HITEC HS-311, 今天就來Hacked成可以角度回饋伺服馬達!<br />
市售HS-311 也有新舊版之分(難道是山寨之分?)如下圖.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkjjQFkNr0NUFCR918EjUTrskpvuS6RlOb9-jXhxoRnyaoDHoTEuL1ceoyZZjpNAh7LgxrM5cx45Qvq4RwPzUzlyhpktWsq72SRAGH4xYJFXhSXd8oMtb1opUOSOsZwfzAEeaSkhgmgqWG/s1600/HITEC_HS-311.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkjjQFkNr0NUFCR918EjUTrskpvuS6RlOb9-jXhxoRnyaoDHoTEuL1ceoyZZjpNAh7LgxrM5cx45Qvq4RwPzUzlyhpktWsq72SRAGH4xYJFXhSXd8oMtb1opUOSOsZwfzAEeaSkhgmgqWG/s1600/HITEC_HS-311.jpg" width="320" /></a></div>
<span id="goog_555236035"></span><span id="goog_555236036"></span><br />
外殼拆開後可以看出電路板走線及IC也不一樣(如下圖), 不過沒關係這種類比伺服馬達原理都一樣利用VR Encoder(可變電阻)來回授位置!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6rhyphenhyphena1jt2yAbsz5veutBDOcVA9hE6AMU30DifEW3Chh8NgeP9-_2Ath4f1-Z-xa83XJ8C3JIdRpdOOiJCZGHP5YVU-nM7yD6a2ik16hQpW8-c_vJa8GHFxZt37ynS53RDOh_L8JbLRRJV/s1600/HITEC_Remove_Cover1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6rhyphenhyphena1jt2yAbsz5veutBDOcVA9hE6AMU30DifEW3Chh8NgeP9-_2Ath4f1-Z-xa83XJ8C3JIdRpdOOiJCZGHP5YVU-nM7yD6a2ik16hQpW8-c_vJa8GHFxZt37ynS53RDOh_L8JbLRRJV/s1600/HITEC_Remove_Cover1.jpg" width="320" /></a></div>
<br />
只要找到Encoder回授信號(電壓值)位置,焊條電線連接出來即可以取的馬達轉動位置電壓值,<br />
利用此電壓值可以換算馬達目前處於哪個角度位置, 焊接位置請參考下圖!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitZJi9z7PhUAWfS1HpbAniYFYsG5dZ9DZtcSqNOu7CaMfH9NMebdTYlE7m93OhxXEZTdTXoNs8XkSZbGQGe7Sv-UxoDpOXBIN_ZF5qO5mrDQqJAc-vYZ6WxpPzndHV1MA86rTbqdyZxKAX/s1600/HITEC_Hacked_Remove_Cover.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitZJi9z7PhUAWfS1HpbAniYFYsG5dZ9DZtcSqNOu7CaMfH9NMebdTYlE7m93OhxXEZTdTXoNs8XkSZbGQGe7Sv-UxoDpOXBIN_ZF5qO5mrDQqJAc-vYZ6WxpPzndHV1MA86rTbqdyZxKAX/s1600/HITEC_Hacked_Remove_Cover.jpg" width="320" /></a></div>
<br />
焊接線完後整理外殼出線位置,讓回饋電線容易拉出及蓋上外殼,如下圖!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigMuovDCzKJLFSNfjX3wIUslgYGOCcCZt5FaYvHiiBoT_vfc1DR1A_hkqUvwauBuBqbZohqJofCTP9AZBW3ymkSab7hMJVwbqxzqAm8cENNHOY0cecVS02O_K8Ddk_4PjRCy7Ue3OcjDuW/s1600/HITEC_Hacked.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigMuovDCzKJLFSNfjX3wIUslgYGOCcCZt5FaYvHiiBoT_vfc1DR1A_hkqUvwauBuBqbZohqJofCTP9AZBW3ymkSab7hMJVwbqxzqAm8cENNHOY0cecVS02O_K8Ddk_4PjRCy7Ue3OcjDuW/s1600/HITEC_Hacked.jpg" width="320" /></a></div>
<br />
<br />
接下來開始寫程式量測回饋訊號電壓及算出角度,Arduino參考程式如下,程式不難容易理解,<br />
把回饋線路接到Arduino A0位置, 主要針對角度 0, 45, 90, 135, 和 180度取得回饋電壓值!<br />
<br />
<br />
#include <Servo.h><br />
<br />
//servo object<br />
Servo myservo;<br />
<br />
//servo position<br />
int pos = 0;<br />
//positions (in degrees) to send to the servo<br />
int positions[] = {0, 45, 90, 135, 180};<br />
int numPositions = 5;<br />
<br />
int numMeasurements = 1;<br />
//increase this value to read feedback multiple times and then calculate the arithmetic average<br />
<br />
void setup()<br />
{<br />
//control servo via pin 9<br />
myservo.attach(3, 650, 2350);<br />
//start serial comm. for debugging<br />
Serial.begin(9600);<br />
}<br />
<br />
void loop()<br />
{<br />
int i = 0;<br />
//iterate over positions<br />
for(i = 0; i < numPositions; i++)<br />
{ <br />
pos = positions[i];<br />
int j = 0;<br />
double sum = 0;<br />
double sensorValue = 0;<br />
<br />
Serial.print("SETTING:");<br />
Serial.println(pos);<br />
myservo.write(pos);<br />
<br />
//wait a bit, to give the servo time to reach the requested position<br />
delay(800);<br />
<br />
//read the feedback via A0, once or multiple times<br />
for(j = 0; j<numMeasurements; j++){ <br />
sum += analogRead(A0);<br />
}<br />
<br />
//calculate average if numMeasurements > 1<br />
sensorValue = (sum/numMeasurements);<br />
Serial.print("READ:");<br />
Serial.println(sensorValue);<br />
<br />
//wait for three seconds<br />
delay(3000);<br />
}<br />
<br />
}<br />
<div>
<br /></div>
<br />
如果調整修改好程式,基本上smart motor改造完成, 可以利用下面程式換算成角度,角度多少會有誤差幾度!<br />
<br />
#include <Servo.h><br />
#include <math.h><br />
<br />
//servo object<br />
Servo myservo;<br />
<br />
//servo position<br />
int pos = 0;<br />
//positions (in degrees) to send to the servo<br />
int positions[] = {0, 45, 90, 135, 180};<br />
int numPositions = 5;<br />
<br />
int numMeasurements = 5;<br />
<br />
//HS-311 servo parameters<br />
int zero_degrees = 98; // HS-311 New version: 94; Old version: 98<br />
double one_degree = 1.5111;//HS-311 New Version: 1.4889; Old version: 1.51111;<br />
<br />
void setup()<br />
{<br />
//control servo via pin 9<br />
myservo.attach(3, 650, 2350);<br />
//start serial comm. for debugging<br />
Serial.begin(9600);<br />
}<br />
<br />
void loop()<br />
{<br />
int i = 0;<br />
//iterate over positions<br />
for(i = 0; i < numPositions; i++)<br />
{ <br />
pos = positions[i];<br />
int j = 0;<br />
double sum = 0;<br />
double sensorValue = 0;<br />
<br />
Serial.println("SETTING:");<br />
Serial.println(pos);<br />
myservo.write(pos);<br />
<br />
//wait a bit, to give the servo time to reach the requested position<br />
delay(800);<br />
<br />
//read the feedback via A0, once or multiple times<br />
for(j = 0; j<numMeasurements; j++){ <br />
sum += analogRead(A0);<br />
}<br />
<br />
//calculate average if numMeasurements > 1<br />
sensorValue = (sum/numMeasurements);<br />
Serial.println("READ:");<br />
Serial.println(calcH311ServoPosition(sensorValue));<br />
<br />
//wait for three seconds<br />
delay(3000);<br />
}<br />
<br />
}<br />
<br />
double calcH311ServoPosition(double val){<br />
val -= zero_degrees;<br />
val /= one_degree;<br />
val = floor(val);<br />
<br />
return val;<br />
}<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
這樣就可以DIY製作出一顆可回授位置的伺服馬達!!<br />
<br />
<br /></div>
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com4tag:blogger.com,1999:blog-9207523769553422691.post-27882615799567029102014-10-07T14:15:00.001+08:002014-10-07T14:15:47.480+08:00Kozig LED I2C介面的七段顯示器: 修改I2C Address<div dir="ltr" style="text-align: left;" trbidi="on">
使用I2C 介面的七段顯示器顯示數字最方便不過了! 此款I2C LED Display 便宜又好用,這次來說明如何修改 I2C Address, 通常買來Address為 0x27.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdtrEuP_uopBZGMOMHggPHt0xGJWPmbNmOPa5_8qZvZjwg1OrjIM8eZuwcsfTPyC_IpTrvzpFPkzHlvjX2F-idsmOiKbRpNppWqnnIpaEgF3fQhxTzIpsLykkQ5Q5bLc9D_cGgiiTdWZBm/s1600/I2C_LED_New1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdtrEuP_uopBZGMOMHggPHt0xGJWPmbNmOPa5_8qZvZjwg1OrjIM8eZuwcsfTPyC_IpTrvzpFPkzHlvjX2F-idsmOiKbRpNppWqnnIpaEgF3fQhxTzIpsLykkQ5Q5bLc9D_cGgiiTdWZBm/s1600/I2C_LED_New1.jpg" height="196" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9UHsianMdW-DcSgEh-EhbtEslwF0EVawEQ8MNrShlAXekW70eFCXn0cGHbB5J1zqVJSbCY1V6ZOJ27TbVyInRpu-GuAILnPalItoviP_0hBlieXICGHSrtqCKNKaKggjDsCqB-xyO_jw-/s1600/I2C_LED_New.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9UHsianMdW-DcSgEh-EhbtEslwF0EVawEQ8MNrShlAXekW70eFCXn0cGHbB5J1zqVJSbCY1V6ZOJ27TbVyInRpu-GuAILnPalItoviP_0hBlieXICGHSrtqCKNKaKggjDsCqB-xyO_jw-/s1600/I2C_LED_New.jpg" height="174" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
步驟如下:<br />
<br />
1.斷電情況下將SCL接到GND, SDA接A4.<br />
2.接通電源,顯示 -51- 時,表示進入設定新地址模式.<br />
3.再將原來SCL接GND改接到A5.<br />
4.執行 SEG8B4A036A_SetAddress, (ztlib example)結束時會顯示新位置.<br />
(下載<a href="http://www.motoduino.com/download-english/category/3-arduino-sketch/" target="_blank">I2C LED</a> 的 Arduino Library)<br />
5. 移除電源,LED 模組已改成新位址!<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrYum9rOxKzKMuhRNRXX9uRAYXBZrCFXc5mGdMdB7T2rUZ4OO0lWEBlSghaL0MlK6Zvcyh-RRr6fRDff-fOUstRHwjyuEcNBU69MO-1aOJIFb5jtSA4ZitKGOIcEr9SchuZCOKOI_WOm7p/s1600/LED_SetAddress.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrYum9rOxKzKMuhRNRXX9uRAYXBZrCFXc5mGdMdB7T2rUZ4OO0lWEBlSghaL0MlK6Zvcyh-RRr6fRDff-fOUstRHwjyuEcNBU69MO-1aOJIFb5jtSA4ZitKGOIcEr9SchuZCOKOI_WOm7p/s1600/LED_SetAddress.jpg" height="239" width="320" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpOr43V4hm85M-vsq-FWMLV_MOtReBencPxbUvo6pu-IrQ4LF3bg2cj5KORNt1sy8MKIeyUxVLMLOk2Qx99E_aJVG5XsydlxpItfRxm1jkhN7ufyl6hLdFwFMA5I4p_ECRRrLPC4rmPhc2/s1600/LED_SetAddress1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpOr43V4hm85M-vsq-FWMLV_MOtReBencPxbUvo6pu-IrQ4LF3bg2cj5KORNt1sy8MKIeyUxVLMLOk2Qx99E_aJVG5XsydlxpItfRxm1jkhN7ufyl6hLdFwFMA5I4p_ECRRrLPC4rmPhc2/s1600/LED_SetAddress1.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://www.motoduino.com/" target="_blank">Motoduino</a> 把此I2C LED連接使用簡單化, 可以利用RJ11 電話線接到 IO Board 的 A4,A5孔位即可使用.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicqqo6Pmslq4tbk9A0fpcL-GZLhJick0AF6xypGBV2BmbSBPI4LIWYpm0r0a7qShLgkrcLv-SvXoGXO7WheONr8IEiUqmshyphenhyphen5SAb6zDJ_CoDNp-9k0P85r78IQXc-9LvSecWvo_vHlV-KT/s1600/Kozig_i2c_led.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicqqo6Pmslq4tbk9A0fpcL-GZLhJick0AF6xypGBV2BmbSBPI4LIWYpm0r0a7qShLgkrcLv-SvXoGXO7WheONr8IEiUqmshyphenhyphen5SAb6zDJ_CoDNp-9k0P85r78IQXc-9LvSecWvo_vHlV-KT/s1600/Kozig_i2c_led.jpg" height="289" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOfpZEhsRPUVOB5O7Pomv0OZfZdPcHuwE806lY-MZDJjf8dvDzXHs9DAmlLn2FEsneX2UoeC7qU8vqKSu2OBdxqC4YIAGC8CrByxvc5wxurCyV1PSQ9NT5jIS8QVQ-6ECabUU692P2BA8M/s1600/IO_Board_I2C_LED.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOfpZEhsRPUVOB5O7Pomv0OZfZdPcHuwE806lY-MZDJjf8dvDzXHs9DAmlLn2FEsneX2UoeC7qU8vqKSu2OBdxqC4YIAGC8CrByxvc5wxurCyV1PSQ9NT5jIS8QVQ-6ECabUU692P2BA8M/s1600/IO_Board_I2C_LED.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com3tag:blogger.com,1999:blog-9207523769553422691.post-20711169235891231852014-09-27T20:14:00.001+08:002014-10-07T14:16:30.064+08:00Arduino I2C LCD 20x4 lines Display<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
這來試試 LCD 20x4 lines, 利用Arduino加上<a href="http://www.motoduino.com/" target="_blank"> IO Board</a> 接線方便許多!<br />
可顯示的字元比 常用LCD 16x2 lines 多許多!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEistI8Iv8nuT8sBRaPSmCpFOqiyK4bemdOGV_TKjkgtRGCEe4b5wdpyzGn3Txt_2ns_P-wmdMWJm4eXP0zYYqcwyIJ5I4Jk4m3f-cHnxpwvI0akoi4HnLdB9ru7qJ8PRQnuAsUCTrR_ZMJu/s1600/I2C_LCD20x4_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEistI8Iv8nuT8sBRaPSmCpFOqiyK4bemdOGV_TKjkgtRGCEe4b5wdpyzGn3Txt_2ns_P-wmdMWJm4eXP0zYYqcwyIJ5I4Jk4m3f-cHnxpwvI0akoi4HnLdB9ru7qJ8PRQnuAsUCTrR_ZMJu/s1600/I2C_LCD20x4_2.jpg" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6QaCV2FB6DpmB_dngrv3t4PsK57iXDaxBxb0WBg6hzYAqOIRxpnKcOow573NfPto7Ak7t8lGe0_T3SXwYIVr_UpIh364XhPv7HKSL9Lq3_OQ2llPbt0i3_g5ZKsnwwcgH0QpLxaP6-PY/s1600/I2C_LCD20x4_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6QaCV2FB6DpmB_dngrv3t4PsK57iXDaxBxb0WBg6hzYAqOIRxpnKcOow573NfPto7Ak7t8lGe0_T3SXwYIVr_UpIh364XhPv7HKSL9Lq3_OQ2llPbt0i3_g5ZKsnwwcgH0QpLxaP6-PY/s1600/I2C_LCD20x4_1.jpg" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYU5OIy1G3iku_08c7ikqPO5WL8hU8IJkrDbuaTwJ_YRrIy7ZZ2-4hibxjQ55btOD16exy5hb54ERHD1GRjNezCP9AHlUkJs9qZBiOc_x19o4aLkXNJZgdXQQEKZjL9l9Y3prcNhoG3f8c/s1600/I2C_LCD20x4_3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYU5OIy1G3iku_08c7ikqPO5WL8hU8IJkrDbuaTwJ_YRrIy7ZZ2-4hibxjQ55btOD16exy5hb54ERHD1GRjNezCP9AHlUkJs9qZBiOc_x19o4aLkXNJZgdXQQEKZjL9l9Y3prcNhoG3f8c/s1600/I2C_LCD20x4_3.jpg" height="239" width="320" /></a></div>
<br />
<br />
步驟一: 下載 <a href="https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads" target="_blank">I2C LCD library</a>, 解壓縮後放入Arduino Libraries內<br />
<br />
步驟二: 撰寫程式如下:<br />
<br />
#include <Wire.h><br />
#include <LiquidCrystal_I2C.h><br />
<br />
// set the LCD address to 0x20 for a 20 chars 4 line display<br />
<br />
LiquidCrystal_I2C lcd(<span style="color: red;">0x27</span>, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address<br />
//假設 I2C address 0x27<br />
<br />
void setup() /*----( SETUP: RUNS ONCE )----*/<br />
{<br />
Serial.begin(9600); /<br />
<br />
lcd.begin(20,4); <br />
for(int i = 0; i< 3; i++)<br />
{<br />
lcd.backlight();<br />
delay(250);<br />
lcd.noBacklight();<br />
delay(250);<br />
}<br />
lcd.backlight();<br />
<br />
lcd.setCursor(3,0); //Start at character 4 on line 0<br />
lcd.print("Motoduino Lab!");<br />
lcd.setCursor(2,1);<br />
lcd.print("www.motoduino.com");<br />
lcd.setCursor(0,2);<br />
lcd.print("20x4 LCD Display");<br />
lcd.setCursor(0,3);<br />
lcd.print("I2C Interface");<br />
<br />
}/*--(end setup )---*/<br />
<br />
<br />
void loop()<br />
{<br />
<br />
}<br />
<br />
<br />
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-77588149800993239812014-09-25T22:16:00.001+08:002014-09-26T08:35:28.790+08:00香蕉派 (Banana Pi) 搭配 MotoPiduino 使用 UART/Serial Console <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
最近拿到一塊 Banana Pi, 馬上就先拿來搭配MotoPiduino, 如果想要利用Serial Console 下命令, 則必須修改 debug 用的 UART Port. 在樹莓派 Raspberry Pi上 只有一個 UART0, 但是在Banana Pi上UART0是不在 26Pin GPIO上(對應Raspberry Pi GPIO)而是在 UART2, 所以就來把Debug UART0 改成 UART2位置,這樣就跟Raspberry 一樣debug UART位置GPIO 26pin.<br />
<br />
步驟:<br />
<br />
1.硬體接線請參考<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Ah-v2n1D-59vucpYsrXkmL3WIdi184HctKSBqtNSYjujrivU4UpYizi13fXgl5ZRHN-ShgNj4Qh1cwlITsPCepaAJK9VBAlLQuL5A814h_xdnvqtRbf94OPgpH5T-UxmwZzMzWiPzvQ0/s1600/USB-to-TTL-Serial-Cable-Debug-Console-Cable-for-Raspberry-Pi-2-800x800.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Ah-v2n1D-59vucpYsrXkmL3WIdi184HctKSBqtNSYjujrivU4UpYizi13fXgl5ZRHN-ShgNj4Qh1cwlITsPCepaAJK9VBAlLQuL5A814h_xdnvqtRbf94OPgpH5T-UxmwZzMzWiPzvQ0/s1600/USB-to-TTL-Serial-Cable-Debug-Console-Cable-for-Raspberry-Pi-2-800x800.jpg" height="320" width="320" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwILJLU41WnVT3O5XQKeEdhC5TO29vhbJ0Hae7Gu6c28ieiUdY0pNjL7fKYBaNdaPmFDB8iOPW7BI2No9OLNQspI-gJlRJs98xYdsX3aOgqlgJbbjj0Uip1_xF8IELNYARdnBRgzjZXyYZ/s1600/BananaPi_UART0.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwILJLU41WnVT3O5XQKeEdhC5TO29vhbJ0Hae7Gu6c28ieiUdY0pNjL7fKYBaNdaPmFDB8iOPW7BI2No9OLNQspI-gJlRJs98xYdsX3aOgqlgJbbjj0Uip1_xF8IELNYARdnBRgzjZXyYZ/s1600/BananaPi_UART0.jpg" height="239" width="320" /></a></div>
<br />
<br />
<br />
二. 修改 inittab 檔案<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7iVDKj7AZF-9vFnuSGEX46ACTZ06Pd5MmvyXpEvpF6E8fb7dnKgIoVCnEBllOd6qB6unEcRWv-qB8D7JfddGuJATDlcioA1hTJPqWLWtGYAxawzze67pMx6BfqLYgiW58xrhtZvQSM8Jp/s1600/change_debug_uart0_to_uart2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7iVDKj7AZF-9vFnuSGEX46ACTZ06Pd5MmvyXpEvpF6E8fb7dnKgIoVCnEBllOd6qB6unEcRWv-qB8D7JfddGuJATDlcioA1hTJPqWLWtGYAxawzze67pMx6BfqLYgiW58xrhtZvQSM8Jp/s1600/change_debug_uart0_to_uart2.png" height="277" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
三. 修改檔案 inittab 最後一行, ttyS0 改成 ttyS2, 存檔後Banana Pi關機!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl2GglBY2ziypJSNS76qV61s2GdBDiKtBSIGoA2oMqg_ikAISS9mE-Gl1g57krlvBiPWlcz-7yOUm7lDs2GMATh7psETJtWo2bWMEOTtk5XYrxKayDKNa847_lRmJsd75BTAviNU_mwaOI/s1600/ttyS2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl2GglBY2ziypJSNS76qV61s2GdBDiKtBSIGoA2oMqg_ikAISS9mE-Gl1g57krlvBiPWlcz-7yOUm7lDs2GMATh7psETJtWo2bWMEOTtk5XYrxKayDKNa847_lRmJsd75BTAviNU_mwaOI/s1600/ttyS2.png" height="277" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
四. 接線換位置如下圖:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEy_dWzZuB2PTTNm3aj7f7AVGmvyXIgojmHs-ZnKmxnjjMZWePNJPMnf0jXExJsdtu1DnSAOsA0l9nw_-5qBM7SQH1fJgq-ghx6Q9zH9KQRL7cTSb-MhNGHwyHL56EIX_-9fBkLEeoaqf_/s1600/Banana_MotoPiduino.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEy_dWzZuB2PTTNm3aj7f7AVGmvyXIgojmHs-ZnKmxnjjMZWePNJPMnf0jXExJsdtu1DnSAOsA0l9nw_-5qBM7SQH1fJgq-ghx6Q9zH9KQRL7cTSb-MhNGHwyHL56EIX_-9fBkLEeoaqf_/s1600/Banana_MotoPiduino.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
五. 重新啓動後初始化訊息還是會從UART0輸出,但是過二三十秒後, PC上的Serial Console (Putty 或 Serial Minitor軟體)會顯示 login 訊息, 此時輸入 bananapi, password也是輸入bananapi, 就進入Console 模式.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
http://www.motoduino.com</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com2tag:blogger.com,1999:blog-9207523769553422691.post-66373504850657138342014-08-03T22:59:00.002+08:002014-08-03T22:59:40.626+08:00Raspberry Pi Software PWM Control = Raspberry Pi (樹莓派) + MotoPiduino + DC Motor <div dir="ltr" style="text-align: left;" trbidi="on">
這個實驗主要利用 RPi.GPIO 的函數庫來實現 PWM 功能, 也就是用軟體模擬 PWM功能, Raspberry Pi只有一 IO 腳位有硬體 PWM, 如需要多個PWM功能可以利用 Softrware PWM.<br />
<br />
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">一.<span style="font-size: 7pt;"> </span></span><span style="font-family: 新細明體, serif;">使用材料 : </span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">1.<span style="font-size: 7pt;"> </span></span><span lang="EN-US"><a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">2.<span style="font-size: 7pt;"> Raspberry Pi</span></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">3.<span style="font-size: 7pt;"> </span></span><span lang="EN-US">5V power</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">4.<span style="font-size: 7pt;"> </span></span><span lang="EN-US">5V DC Motor</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmP0ZxZKJAkknGNDy29oHVtF_ZMi9owPfi6H3lzbe7E45YTsJgS3pIs4UAwh0ES5qhzakKvW5TGFlg2YZ4RfQkXsV9fwGPcBSSlybaQCUONa8saKFhktzeXlFZLmRNQVhgvzBSol_-0OKl/s1600/motopiduino_motor1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmP0ZxZKJAkknGNDy29oHVtF_ZMi9owPfi6H3lzbe7E45YTsJgS3pIs4UAwh0ES5qhzakKvW5TGFlg2YZ4RfQkXsV9fwGPcBSSlybaQCUONa8saKFhktzeXlFZLmRNQVhgvzBSol_-0OKl/s1600/motopiduino_motor1.jpg" height="239" width="320" /></a></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTVMG5z1X2tMqcr_BgwxOMYNafmQoP_iJX729AuZaSo5WaVXTuq2YiLW8LDTqS3sdFTqDXqW4sQGxuDOZLTNQA5Zps7G36AnDCJwbuEs-6TsVTt11X5Bvsw4RP1z9qtG5b2PtMrOnxe2Dl/s1600/motopiduino_motor2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTVMG5z1X2tMqcr_BgwxOMYNafmQoP_iJX729AuZaSo5WaVXTuq2YiLW8LDTqS3sdFTqDXqW4sQGxuDOZLTNQA5Zps7G36AnDCJwbuEs-6TsVTt11X5Bvsw4RP1z9qtG5b2PtMrOnxe2Dl/s1600/motopiduino_motor2.jpg" height="239" width="320" /></a></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">二. 程式: </span>編寫Python 程式 motor_pwm.py </div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="MsoListParagraph" style="background-color: white; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">import RPi.GPIO as GPIO</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">from time import sleep</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setmode(GPIO.BOARD)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setup(11, GPIO.OUT)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setup(12, GPIO.OUT)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setup(13, GPIO.OUT)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setup(15, GPIO.OUT)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">p11=GPIO.PWM(11, 100)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">p12=GPIO.PWM(12, 100)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">p11.start(0)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">p12.start(0)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">try:</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> while True:</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> for i in range(0, 101):</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p11.ChangeDutyCycle(i)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p12.ChangeDutyCycle(i)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(13, False)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(15, False)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> sleep(0.2)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> for i in range(100,-1,-1):</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p11.ChangeDutyCycle(i)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p12.ChangeDutyCycle(i)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(13, False)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(15, False)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> sleep(0.2)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">except KeyboardInterrupt:</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p11.stop()</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p12.stop()</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(11, 0)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(12, 0)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(13, 0)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(15, 0)</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.cleanup()</span></span></div>
<div class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> </span></span></div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<br /></div>
</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><span style="text-indent: 0px;">三. 執行:</span><br style="text-indent: 0px;" /><span style="text-indent: 0px;"> $ sudo python motor_pwm.py</span></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><span style="text-indent: 0px;"><br /></span></span></div>
<div class="MsoListParagraph" style="background-color: white; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><span style="font-size: 15px; line-height: 20.790000915527344px; text-indent: 0px;"><span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"> 示範影片: <a href="https://www.youtube.com/watch?v=LJvqxhu6nF8">https://www.youtube.com/watch?v=LJvqxhu6nF8</a></span></span></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><span style="text-indent: 0px;"><br /></span></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"> Information : <a href="http://www.motoduino.com/">http://www.motoduino.com</a></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US"><br /></span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<br /></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<br /></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com4tag:blogger.com,1999:blog-9207523769553422691.post-8790870117906351232014-07-06T23:00:00.001+08:002014-08-06T17:19:53.658+08:00android 手機遙控車 = Motoduino (Arduino + L293D) + bluetooth (藍牙) + 19cm 圓形車體<div dir="ltr" style="text-align: left;" trbidi="on">
這次挑選一款品質還不錯的車體來做Android手機遙控車!<br />
<br />
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">一.<span style="font-size: 7pt;"> </span></span><span style="font-family: 新細明體, serif;">使用材料 : (<a href="http://goods.ruten.com.tw/item/show?21406209016146" style="color: #6699cc; text-decoration: none;" target="_blank">材料購買網站</a>)</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">1.<span style="font-size: 7pt;"> </span></span><span lang="EN-US"><a href="http://www.motoduino.com/" style="color: #6699cc; text-decoration: none;" target="_blank">Motoduino</a> 或 Arduino + 馬達驅動板</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">2.<span style="font-size: 7pt;"> </span></span><span lang="EN-US">TTL</span><span style="font-family: 新細明體, serif;">藍芽模組</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">3.<span style="font-size: 7pt;"> </span></span><span lang="EN-US">9V</span><span style="font-family: 新細明體, serif;">電池一顆</span> <span style="font-family: 新細明體, serif;">及</span> <span style="font-family: 新細明體, serif;">電池釦線</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">4.<span style="font-size: 7pt;"> </span></span><span lang="EN-US">USB</span><span style="font-family: 新細明體, serif;">傳輸線</span><span lang="EN-US"> (</span><span style="font-family: 新細明體, serif;">下載程式用</span><span lang="EN-US">)</span></div>
<div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; margin-left: 18pt; text-indent: -18pt;">
<span lang="EN-US">5.<span style="font-size: 7pt;"> </span></span><span style="font-family: 新細明體, serif;">小車體套件包</span><br />
<span style="font-family: 新細明體, serif;"><br /></span>
<span style="font-family: 新細明體, serif;">完成圖:</span><br />
<span style="font-family: 新細明體, serif;"> </span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: 新細明體, serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxiVaaaQUhRrcMAMDFRQPuH01CryMcGPPxq_OHrvn9NZ5iMQMgRQ1iobM7B1TtP_GIBWT7Z6dYv4zPknThqnXiDTvwwprBVWdbtWJG4F8GTw6ly4Tb4qu4kNYBRJcCoxKmkBov12lMSYHi/s1600/Robot2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxiVaaaQUhRrcMAMDFRQPuH01CryMcGPPxq_OHrvn9NZ5iMQMgRQ1iobM7B1TtP_GIBWT7Z6dYv4zPknThqnXiDTvwwprBVWdbtWJG4F8GTw6ly4Tb4qu4kNYBRJcCoxKmkBov12lMSYHi/s1600/Robot2.jpg" height="239" width="320" /></a></span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: 新細明體, serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG6DEZgaANMy1lnBCMwlyIZd7p2Y9JmE393t46F1GrQSDST4FdUJeU8MuvgP6EfzVZIm1MlwcOlS4xCTBkRt5OC2iAiuSYFSQ9BAaK1ClK6WEqVUKTRHzuMvsbuoSMWEemmER6Cua2nsm7/s1600/Robot1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG6DEZgaANMy1lnBCMwlyIZd7p2Y9JmE393t46F1GrQSDST4FdUJeU8MuvgP6EfzVZIm1MlwcOlS4xCTBkRt5OC2iAiuSYFSQ9BAaK1ClK6WEqVUKTRHzuMvsbuoSMWEemmER6Cua2nsm7/s1600/Robot1.jpg" height="239" width="320" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: 新細明體, serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: 新細明體, serif;"><br /></span></div>
<br />
<span style="font-family: 新細明體, serif;">二. 安裝過程:</span><br />
<span style="font-family: 新細明體, serif;"><br /></span>
<br />
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-size: medium;"><b><span style="font-family: 新細明體, serif;">Step 1</span><span lang="EN-US">: </span></b></span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-family: 新細明體, serif;"> 圖一是所有組裝材料</span><span style="font-family: 新細明體, serif;">,</span><span style="font-family: 新細明體, serif;">首先可以先把車子底盤兩面的土黃色貼紙撕下</span><span style="font-family: 新細明體, serif;">,需要花點時間撕下因為黏膠很強,或不撕保持貼紙在上面也可以。</span></div>
<br />
<span style="font-family: 新細明體, serif;"><br /></span>
<span style="font-family: 新細明體, serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwp5VSEFYlS6nO6OoEd5QOMajC_e6hbaczBxuP9RSJDFA-98PAZqO47fZPB4g_lssE_8C_227NByZWIYExEy1F04KGxXrPdKdQw6hCy6T61A4jp-qioT2mwv_Fp3_r8cUIRXogpMaaDc2x/s1600/partslist.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwp5VSEFYlS6nO6OoEd5QOMajC_e6hbaczBxuP9RSJDFA-98PAZqO47fZPB4g_lssE_8C_227NByZWIYExEy1F04KGxXrPdKdQw6hCy6T61A4jp-qioT2mwv_Fp3_r8cUIRXogpMaaDc2x/s1600/partslist.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
圖一</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-size: medium;"><b><span style="font-family: 新細明體, serif;">Step 2</span><span lang="EN-US">:</span></b></span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-family: 新細明體, serif;"> 利用螺絲及馬達固定鐵片先固定在車子底盤上</span><span style="font-family: 新細明體, serif;">,以及兩個舵輪</span><span style="font-family: 新細明體, serif;">如圖二圖三</span><span style="font-family: 新細明體, serif;">。</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBfR61PEY731Mt0-3-HRG6Zhn-N6rrDHcVEB_tefAF32oYMKLdwGKZp1eYlYlDRvFNbIF2Z4enUbYrbYKUNMa1oE9ckvlhR1sK_sUu37CljZW4lBzaO3l1bN4NtNcpcFpeTKydDoGwwO-a/s1600/PartsDown.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBfR61PEY731Mt0-3-HRG6Zhn-N6rrDHcVEB_tefAF32oYMKLdwGKZp1eYlYlDRvFNbIF2Z4enUbYrbYKUNMa1oE9ckvlhR1sK_sUu37CljZW4lBzaO3l1bN4NtNcpcFpeTKydDoGwwO-a/s1600/PartsDown.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
圖二 (車體底部)</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwcaBZmpc3fkfJnRSYWNgDiIqfIlyJNGw1CZ3WvHIYr5qilo4h64YyBdZcrh9ccadyyGqlUfAIpXoZRlEBNjuesWdwaMSZVOxyZ5IyWvRygBNxu5r2_10QZzD8z5hBGREMG7BhXoVOozdp/s1600/PartsUp.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwcaBZmpc3fkfJnRSYWNgDiIqfIlyJNGw1CZ3WvHIYr5qilo4h64YyBdZcrh9ccadyyGqlUfAIpXoZRlEBNjuesWdwaMSZVOxyZ5IyWvRygBNxu5r2_10QZzD8z5hBGREMG7BhXoVOozdp/s1600/PartsUp.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
圖三 (車體頂部)</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-size: medium;"><b><span style="font-family: 新細明體, serif;">Step 3</span><span lang="EN-US">:</span></b></span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-family: 新細明體, serif;"> 四顆電池盒先固定於下層板(圖四)</span><span style="font-family: 新細明體, serif;">,再</span><span style="font-family: 新細明體, serif;">利用最長的螺絲把馬達固定在L型鐵片上</span><span style="font-family: 新細明體, serif;">。</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqj-4I-PSFob7TvO8xNFrpir2HktoDDovLFCifFGjyGuZJZ3eR092A7SbXyR0sJqXPWBCu9_PDqokrSxnvGX1zK_FguywTJp8yLPLvDa-xhleeYMUiLeQq2e7pI_0GPTd5ChP_pWtnN42t/s1600/batterycase.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqj-4I-PSFob7TvO8xNFrpir2HktoDDovLFCifFGjyGuZJZ3eR092A7SbXyR0sJqXPWBCu9_PDqokrSxnvGX1zK_FguywTJp8yLPLvDa-xhleeYMUiLeQq2e7pI_0GPTd5ChP_pWtnN42t/s1600/batterycase.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
圖四</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: 新細明體, serif;"><br /></span>
<br />
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-size: medium;"><b><span style="font-family: 新細明體, serif;">Step 4</span><span lang="EN-US">:</span></b></span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-family: 新細明體, serif;"> 組裝最上層底板及利用兩根螺絲固定Motoduino於板子</span><span style="font-family: 新細明體, serif;">如圖五</span><span style="font-family: 新細明體, serif;">。</span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-family: 新細明體, serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyAfw3-cvUwfDvwcp2CPBG3sks1ZR1Ru8wsshPdxb5CCM5lzGAgn4Tih3oMWXyhNg9bH2CiV5hMrmf00EYhVolxDrTOUu60-1lQGLuxC4CM0IC6NsbqR6tf5Tz9EkNhFyenCZbCuAYtSnP/s1600/Robot2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyAfw3-cvUwfDvwcp2CPBG3sks1ZR1Ru8wsshPdxb5CCM5lzGAgn4Tih3oMWXyhNg9bH2CiV5hMrmf00EYhVolxDrTOUu60-1lQGLuxC4CM0IC6NsbqR6tf5Tz9EkNhFyenCZbCuAYtSnP/s1600/Robot2.jpg" height="239" width="320" /></a></div>
<div style="text-align: center;">
<span style="font-family: 新細明體, serif;">圖五</span></div>
<div style="text-align: center;">
<span style="font-family: 新細明體, serif;"><br /></span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-size: medium;"><b><span style="font-family: 新細明體, serif;">Step 5</span><span lang="EN-US">:</span></b></span></div>
<div class="MsoNormal" style="text-indent: 0px;">
<span style="font-family: 新細明體, serif;"> 連接馬達線路</span><span style="font-family: 新細明體, serif;">如圖六</span><span style="font-family: 新細明體, serif;">。電池盒電線可以不用接到板子上</span><span style="font-family: 新細明體, serif;">,如果要接上提供馬達電源則需把J5的Jump跳到Ext. Vin的位置(板子內設為馬達電源板子提供)</span><span style="font-family: 新細明體, serif;">。</span></div>
<div>
<span style="font-family: 新細明體, serif;"><br /></span></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggGsDrlvonyeSlaApr5Zt9jK7qNIW9-TxJyeU6jtROKud9IurlB5Dm_plScn0J2apdSDeSsLDsz-DB1iDqAuKzEATKeP_gT4aXwfDvzzYKjuMILFWYSOpBPmAJupA9jh-75wO8AogXT90k/s1600/MotoRobot.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggGsDrlvonyeSlaApr5Zt9jK7qNIW9-TxJyeU6jtROKud9IurlB5Dm_plScn0J2apdSDeSsLDsz-DB1iDqAuKzEATKeP_gT4aXwfDvzzYKjuMILFWYSOpBPmAJupA9jh-75wO8AogXT90k/s1600/MotoRobot.jpg" height="240" width="320" /></a></div>
<div style="text-align: center;">
圖六</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
資料參考:<br />
遙控車程式參考: <a href="http://sinocgtchen.blogspot.tw/2013/09/raspberry-pipart-1-motopiduino.html">http://sinocgtchen.blogspot.tw/2013/09/raspberry-pipart-1-motopiduino.html</a></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">部落格: </span><a href="http://sinocgtchen.blogspot.com/" style="color: #6699cc; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">http://sinocgtchen.blogspot.com/</a></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<span style="line-height: 20px;">影片: </span><a href="http://www.youtube.com/user/sinocgtchen" style="color: #6699cc; line-height: 20px;">http://www.youtube.com/user/sinocgtchen</a></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<span lang="EN-US">Motoduino介紹網站: <a href="http://www.motoduino.com/" style="color: #6699cc; text-decoration: none;">http://www.motoduino.com</a> (source code下載處)</span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<span lang="EN-US"><br /></span></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com8tag:blogger.com,1999:blog-9207523769553422691.post-19401199550150334262014-05-02T18:54:00.002+08:002014-07-13T22:05:26.383+08:00 樹莓派PIR 紅外線人體感測( Motion Detection) = PIR Sensor + MotoPiduino + Raspberry Pi<div dir="ltr" style="text-align: left;" trbidi="on">
由於一般市售PIR紅外線大都是 3.3V輸出,也就是感測到移動物體時輸出 3.3V, 沒感測到時輸出 0V, 所以在MotoPiduino 板子上直接接到數位IO腳位無法判讀輸出結果,因為未達5V電壓, 此MotoPiduino是把5V電壓轉換成 3.3V樹莓派可以運作的電位. 如此我們可以利用類比IO腳位來判讀是否偵測到移動物體.<br />
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">一. 使用材料:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 1. Raspberry Pi</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 2. <a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a></span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 3. PIR 紅外線感測器</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 4. S4A IO Board (option)</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;" />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">二. 接線:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 1. 把 PIR 接到 MotoPiduino A0 位置</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 或</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 直接接到 S4A IO Board 的 A0 孔位</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">三. 接線方式如圖:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjewsqpNDuqtD_THSarAqR5Ca1v3WZeq7PrdYLE7n4PnUgiCCDfdjOpLg-E-UOs1YKi4yKeyC84gSqXQuMrQPf2QF-HAjedk6EjPHrI7caS6WqLbTvgPha3jHtW0SI3b6pa-4MaE5D7mYNP/s1600/motopiduino_PIR_connect.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjewsqpNDuqtD_THSarAqR5Ca1v3WZeq7PrdYLE7n4PnUgiCCDfdjOpLg-E-UOs1YKi4yKeyC84gSqXQuMrQPf2QF-HAjedk6EjPHrI7caS6WqLbTvgPha3jHtW0SI3b6pa-4MaE5D7mYNP/s1600/motopiduino_PIR_connect.JPG" height="239" width="320" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIhIXcOltEQX-ZNZRfltPxY6z1cHdketkFSqmxHD6wgwCq-eCUkGAWL73T_Ezlmom3kfoRPifAIEZzWrmWwEAQHmR6gfjQmMmPkuBaLfwpCn8xOb2WT8kLBiG4cA8wevTvUXyTZ_uIflLF/s1600/Motoduino_IO_PIR.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIhIXcOltEQX-ZNZRfltPxY6z1cHdketkFSqmxHD6wgwCq-eCUkGAWL73T_Ezlmom3kfoRPifAIEZzWrmWwEAQHmR6gfjQmMmPkuBaLfwpCn8xOb2WT8kLBiG4cA8wevTvUXyTZ_uIflLF/s1600/Motoduino_IO_PIR.JPG" height="239" width="320" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<br />
<div class="separator" style="background-color: white; clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
四. I2C Library 軟體下載點:</div>
1. 下載 ADS1015 (I2C) Library : <a href="https://github.com/m3m0ry/Adafruit-Raspberry-Pi-Python-Code" style="color: #6699cc; text-decoration: none;">https://github.com/m3m0ry/Adafruit-Raspberry-Pi-Python-Code</a><br />
2. 編寫Python PIR 程式 my_PIR_sensor.py 如下(請該檔案建立在adafruit_ADS1x15目錄下)<br />
<div class="separator" style="background-color: white; clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<br /></div>
<div class="separator" style="background-color: white; clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
</div>
<div class="MsoNormal">
<span lang="EN-US">import time, signal, sys</span></div>
<div class="MsoNormal">
<span lang="EN-US">from Adafruit_ADS1x15 import ADS1x15</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US">def signal_handler(signal, frame):</span></div>
<div class="MsoNormal">
<span lang="EN-US">
print 'You pressed Ctrl+C!'</span></div>
<div class="MsoNormal">
<span lang="EN-US">
sys.exit(0)</span></div>
<div class="MsoNormal">
<span lang="EN-US">signal.signal(signal.SIGINT,
signal_handler)</span></div>
<div class="MsoNormal">
<span lang="EN-US">#print 'Press Ctrl+C to exit'</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US">ADS1015 = 0x00 # 12-bit ADC</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US">adc = ADS1x15(ic=ADS1015)</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US">while True:</span></div>
<div class="MsoNormal">
<span lang="EN-US"> #
Read channel 0 in single-ended mode, +/-4.096V, 250sps</span></div>
<div class="MsoNormal">
<span lang="EN-US">
volts = adc.readADCSingleEnded(0, 4096, 250) / 1000</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US">
print "Channel 0 = %.6f" % (volts)</span></div>
<div class="MsoNormal">
<span lang="EN-US">
if(volts > 3.0): </span></div>
<div class="MsoNormal">
<span lang="EN-US">
print "Detected something..."</span></div>
<div class="MsoNormal">
<span lang="EN-US">
else:</span></div>
<div class="MsoNormal">
<span lang="EN-US">
print "detected nothing..."</span></div>
<div class="MsoNormal">
<span lang="EN-US"> </span></div>
<div class="MsoNormal">
<span lang="EN-US">
time.sleep(1)</span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US">五. 執行:<br /> $ sudo python my_PIR_sensor.py</span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4MHyPQBdFUBjDON2OCwimLMvcwN818nNQKZAMckNerLWbVIXCTe-506lJGdejVTb6USa1j6gelR92JJVIeU8TVhCvriC-KoWjggI3JSj78T4Sor82_BuKU-ffeUDOe9XCT8fxVymAlgRT/s1600/Motopiduino_PIR_data.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4MHyPQBdFUBjDON2OCwimLMvcwN818nNQKZAMckNerLWbVIXCTe-506lJGdejVTb6USa1j6gelR92JJVIeU8TVhCvriC-KoWjggI3JSj78T4Sor82_BuKU-ffeUDOe9XCT8fxVymAlgRT/s1600/Motopiduino_PIR_data.JPG" height="239" width="320" /></a></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US">Informatiom: <a href="http://www.motoduino.com/">http://www.motoduino.com</a></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-49317849823583314032014-04-25T14:09:00.000+08:002014-07-13T22:05:38.520+08:00樹莓派超音波測距 = Raspberry + Ultrasonic HC-SR04 + MotoPiduino<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">一. 使用材料:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 1. Raspberry Pi</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 2. <a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a></span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 3. 超音波 HC-SR04</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 4. S4A IO Board (option)</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;" />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">二. 接線:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 1. 把 HC-SR04 接到 MotoPiduino D10 及 D11 位置, (樹莓派 GPIO8(TRIGGER) 和 GPIO10(ECHO) 位置)</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 或</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 直接接到 S4A IO Board 的 D10 D11孔位</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;" />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">三. 接線方式如圖:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> </span><br />
<span style="background-color: white;"><span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> </span></span></span><br />
<div class="separator" style="clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkrCnW_5n0-DQ_MTBjMSZJPJuLDfe_c9sKLVI-TPrRr51GG-dKkDG5yMgmeRzSPFSbcRd4WwQ71gLxMTUcG2oKs6qsyBYB-FyseTHrDYmzTafW1IdJ4ElNckWw0UCkOrqYXM7UYYpFRerF/s1600/ultrasonic_1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkrCnW_5n0-DQ_MTBjMSZJPJuLDfe_c9sKLVI-TPrRr51GG-dKkDG5yMgmeRzSPFSbcRd4WwQ71gLxMTUcG2oKs6qsyBYB-FyseTHrDYmzTafW1IdJ4ElNckWw0UCkOrqYXM7UYYpFRerF/s1600/ultrasonic_1.JPG" height="239" width="320" /></a></div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<br /></div>
<div class="separator" style="clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyJCVfxRIItM5o7AVFDurqgVi75CyApWHjAsVAx1PYnyg9d9TJBWADGxm5om5Uj2mFGddmOuowWBkfO77WO4jQFbPWVmUZc7tH-J4gTG8gV5OMGxgROQIgyKJPhUXLf96NEAcu8uO2jvDR/s1600/ultrasonic_2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyJCVfxRIItM5o7AVFDurqgVi75CyApWHjAsVAx1PYnyg9d9TJBWADGxm5om5Uj2mFGddmOuowWBkfO77WO4jQFbPWVmUZc7tH-J4gTG8gV5OMGxgROQIgyKJPhUXLf96NEAcu8uO2jvDR/s1600/ultrasonic_2.JPG" height="239" width="320" /></a></div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">
<br /></div>
<div class="separator" style="clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg91xkNBr9KvsuinES_MrI5H9iHWYFGjD1MmiMfqjn8l0tMlVrF_l86VN-PiiLuezMLGT2eUTG8mYZAOFdZJWQcHavG7ht6OWKf_kiXPsHsDqr1gkPx58UyaiJcLKVGqe3Za5F8DA0qhq75/s1600/ultrasonic_3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg91xkNBr9KvsuinES_MrI5H9iHWYFGjD1MmiMfqjn8l0tMlVrF_l86VN-PiiLuezMLGT2eUTG8mYZAOFdZJWQcHavG7ht6OWKf_kiXPsHsDqr1gkPx58UyaiJcLKVGqe3Za5F8DA0qhq75/s1600/ultrasonic_3.JPG" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; text-align: left;">
4. 編寫程式:</div>
<div class="separator" style="clear: both; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px; text-align: left;">
<span style="background-color: transparent;"># -----------------------</span></div>
<br />
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Import required Python libraries</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># -----------------------</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">import time</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">import RPi.GPIO as GPIO</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># -----------------------</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Define some functions</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># -----------------------</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">def measure():</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> # This function measures a distance</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(GPIO_TRIGGER, True)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> time.sleep(0.00001)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.output(GPIO_TRIGGER, False)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> start = time.time()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> </span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> while GPIO.input(GPIO_ECHO)==0:</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> start = time.time()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> while GPIO.input(GPIO_ECHO)==1:</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> stop = time.time()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> elapsed = stop-start</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance = (elapsed * 34300)/2</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> return distance</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">def measure_average():</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> # This function takes 3 measurements and</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> # returns the average.</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance1=measure()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> time.sleep(0.1)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance2=measure()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> time.sleep(0.1)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance3=measure()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance = distance1 + distance2 + distance3</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance = distance / 3</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> return distance</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># -----------------------</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Main Script</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># -----------------------</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Use BCM GPIO references</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># instead of physical pin numbers</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setmode(GPIO.BCM)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Define GPIO to use on Pi</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO_TRIGGER = 8</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO_ECHO = 10</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">print "Ultrasonic Measurement"</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Set pins as output and input</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setup(GPIO_TRIGGER,GPIO.OUT) # Trigger</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.setup(GPIO_ECHO,GPIO.IN) # Echo</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"># Set trigger to False (Low)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">GPIO.output(GPIO_TRIGGER, False)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">try:</span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> while True:</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> distance = measure_average()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> print "Distance : %.1f" % distance</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> time.sleep(1)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">except KeyboardInterrupt:</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> # User pressed CTRL-C</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> # Reset GPIO settings</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> GPIO.cleanup()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;">五. 相關資訊:</span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">相關資訊: </span><a href="http://motoduino.com/">http://motoduino.com</a></div>
<div>
<br /></div>
<div>
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-18123646879874873982014-04-17T11:17:00.004+08:002014-04-26T23:23:58.058+08:00樹莓派LCD顯示器 = Raspberry Pi + MotoPiduino + I2C LCD 16x2 <div dir="ltr" style="text-align: left;" trbidi="on">
這次來說明如何把I2C LCD1602接到 Raspberry 上顯示文字及IP address, I2C LCD好處只需要佔用2支IO腳位.<br />
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">一. 使用材料:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 1. Raspberry Pi</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 2. MotoPiduino</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 3. I2C LCD1602</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 4. S4A Sensor Board (option)</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;" />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">二. 接線:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 1. 把 LCD1602 接到 A4 (SDA) and A5 (SCL) 位置</span><br />
或<br />
直接接到 S4A IO Board 的 A4A5孔位<br />
<br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;" />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">三. 接線方式如圖:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> </span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgsaIyJZqeW9drj9O3LKTjjefwqyDIP-CjxthV6yZvcKozrK9HSwBlgdsjGVmFbOVUSa8s4mY__UDkWhJz4LKrQ9HF7aBuls7ZXuRxbRuSTRjyiCAiokWuqy3ZkD7upn70YYzfXXgrhEFT/s1600/I2C_LCD_connected1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgsaIyJZqeW9drj9O3LKTjjefwqyDIP-CjxthV6yZvcKozrK9HSwBlgdsjGVmFbOVUSa8s4mY__UDkWhJz4LKrQ9HF7aBuls7ZXuRxbRuSTRjyiCAiokWuqy3ZkD7upn70YYzfXXgrhEFT/s1600/I2C_LCD_connected1.jpg" height="320" width="240" /></a></span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiA-Neg4u84_6WnUrbrRMVDCOQyOBrt7i4Rts4BBVVyW5a-1-tHQR8qwcSBgLxIb4kmuqyejt4fzBWEHhMXUd4sU1X_PdW46iW3amPIPZEDmXT6A6nIKG3NgGp46xvbPgiAMBkzEnHB2r8/s1600/I2C_LCD_connected.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiA-Neg4u84_6WnUrbrRMVDCOQyOBrt7i4Rts4BBVVyW5a-1-tHQR8qwcSBgLxIb4kmuqyejt4fzBWEHhMXUd4sU1X_PdW46iW3amPIPZEDmXT6A6nIKG3NgGp46xvbPgiAMBkzEnHB2r8/s1600/I2C_LCD_connected.jpg" height="240" width="320" /></a></span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOIrX5Rp_4QxZl61lglHkxhe7EEkhMlo_uSNlQP7UgNF90M9XdD0Os0kRzcWUXyBq5_LPpXFUSM2XEKdtZVbUNotm6N3TvfEq-P6sZaDzdiKtHIYdcDrliTVgOOfAwcvHQrUbRomwx-Tzn/s1600/motopiduino_i2c_lcd_1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOIrX5Rp_4QxZl61lglHkxhe7EEkhMlo_uSNlQP7UgNF90M9XdD0Os0kRzcWUXyBq5_LPpXFUSM2XEKdtZVbUNotm6N3TvfEq-P6sZaDzdiKtHIYdcDrliTVgOOfAwcvHQrUbRomwx-Tzn/s1600/motopiduino_i2c_lcd_1.JPG" height="239" width="320" /></a></div>
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">四. I2C LCD Library 軟體下載點:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">1. 建立一個目錄及下載程式: </span><span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><a href="https://github.com/paulbarber/raspi-gpio">https://github.com/paulbarber/raspi-gpio</a></span></span><br />
2. 檢查LCD的 I2C 位置(需事先開啟I2C功能), 此例子為0x27, 如下圖:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYAdgMI8rYk5KHNlHFyEnAeSUmTCZgNiJKrj7ITKIFGy4cqWxunD-YvGU3i1jkX4WnEajiVc3A2O-YZIxK053L9fIzbXQGQKvHcxhxRiJ9l14xktqbwWYGxlyV94JowPopOVoOFlAkSWLU/s1600/motopiduino_i2c_lcd_address2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYAdgMI8rYk5KHNlHFyEnAeSUmTCZgNiJKrj7ITKIFGy4cqWxunD-YvGU3i1jkX4WnEajiVc3A2O-YZIxK053L9fIzbXQGQKvHcxhxRiJ9l14xktqbwWYGxlyV94JowPopOVoOFlAkSWLU/s1600/motopiduino_i2c_lcd_address2.JPG" height="320" width="239" /></a></div>
<br />
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">3. 修改 lcd_display.py 內的LCD ADDRESS 如下圖:</span><br />
<br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="background-color: white; font-size: 15px; line-height: 20.790000915527344px;"> </span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUhLr9CIvdTuzJDF-lu_tmWcrcKQic8Bji2BCAkDufDO3UbXMONPryUJOS_qMCrK5xKe3wTl6PjQyIGWktBf_J1puEtVn8SnLTXb72VIiKwhFAjP9cnJs6tES82aqq3-ijI41xA5CUsEIS/s1600/motopiduino_i2c_lcd_address.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUhLr9CIvdTuzJDF-lu_tmWcrcKQic8Bji2BCAkDufDO3UbXMONPryUJOS_qMCrK5xKe3wTl6PjQyIGWktBf_J1puEtVn8SnLTXb72VIiKwhFAjP9cnJs6tES82aqq3-ijI41xA5CUsEIS/s1600/motopiduino_i2c_lcd_address.JPG" height="239" width="320" /></a></span></div>
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> 4. </span><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">編寫LCD 測試程式 lcd_i2c_test.py 如下(請將該檔案建立在剛下載的Library目錄下)</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> from lcd_display import lcd</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> from subprocess import *</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span>
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> my_lcd = lcd()</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span>
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> cmd = "ip addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span>
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> def run_cmd(cmd):</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> p = Popen(cmd, shell=True, stdout=PIPE)</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> output = p.communicate()[0]</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> return output</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"><br /></span></span>
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> ipaddr = run_cmd(cmd)</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> ipaddrstr = 'IP:' + ipaddr </span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> my_lcd.display_string("Motoduino Lab", 1)</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20.790000915527344px;"> my_lcd.display_string(ipaddrstr, 2)</span></span><br />
<span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="background-color: white; font-size: 15px; line-height: 20.790000915527344px;"></span></span><br />
<br />
<br />
<br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">五. 執行:</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> $ sudo python lcd_i2c_test.py</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZxRPw5Nm4vePd-Dvdi1WNSigwsRyzKtCRFM-ZoVxRWdA6M4P30aUMWw_WPJiwlecj6SUPoOyTMvhVHEYGivSl8Btoc8VGup1y9SLgsDnwTR2r5tDLM9ygkxd-Q3LtRy8H4sUPXHOz4sBm/s1600/motopiduino_i2c_lcd_2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZxRPw5Nm4vePd-Dvdi1WNSigwsRyzKtCRFM-ZoVxRWdA6M4P30aUMWw_WPJiwlecj6SUPoOyTMvhVHEYGivSl8Btoc8VGup1y9SLgsDnwTR2r5tDLM9ygkxd-Q3LtRy8H4sUPXHOz4sBm/s1600/motopiduino_i2c_lcd_2.JPG" height="239" width="320" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;">相關資訊: <a href="http://motoduino.com/">http://motoduino.com</a></span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"> </span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20.790000915527344px;"><br /></span></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-29522061723823511572014-04-16T21:07:00.005+08:002014-07-13T22:05:56.154+08:00樹莓派溫度感測 = Raspberry Pi + MotoPiduino + LM35 + S4A IO Board <div dir="ltr" style="text-align: left;" trbidi="on">
利用 MotoPiduino的 ADC(Analog to Digital) 和 I2C 功能特點來製作一個溫度感測裝置.<br />
<br />
一. 使用材料:<br />
1. Raspberry Pi<br />
2. <a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a><br />
3. LM35 temperature Sensor<br />
4. S4A Sensor Board (option)<br />
<br />
二. 接線:<br />
1. LM35 接在 A0 (Analog 0位置)<br />
<br />
三. 接線方式如圖:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjADJX0DbJKql_hABA3moQvlRcxeGQU3iw234faLtohDJrhDe7eBNEUSscxmH7TNGTM0OOXlDOWPKgh54oif4EpGiyJgwCBKToaBI1BHoCo3Bbs3jE36GgEVZHy6Ritv_gC_wnGKUqrPLiY/s1600/motopiduino_lm35_1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjADJX0DbJKql_hABA3moQvlRcxeGQU3iw234faLtohDJrhDe7eBNEUSscxmH7TNGTM0OOXlDOWPKgh54oif4EpGiyJgwCBKToaBI1BHoCo3Bbs3jE36GgEVZHy6Ritv_gC_wnGKUqrPLiY/s1600/motopiduino_lm35_1.JPG" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauNVv6aYE6HdGFXMZA5L0K-k6AFf9CyxrE1nfv09KxsW3xXeehVsCJv_8dncc_I6cDUj85x6XcJOyHJsZrE1WelT2noc9NvuIkmdn2-hAZs4Ir7NUqJbWGm60P8NnaekMEFu6luC4lip7/s1600/motopiduino_lm35_2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauNVv6aYE6HdGFXMZA5L0K-k6AFf9CyxrE1nfv09KxsW3xXeehVsCJv_8dncc_I6cDUj85x6XcJOyHJsZrE1WelT2noc9NvuIkmdn2-hAZs4Ir7NUqJbWGm60P8NnaekMEFu6luC4lip7/s1600/motopiduino_lm35_2.JPG" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVYvpU3VXmoU9mUc7i1pjmeaUhRFk8jBAeKp8xQgGt4jOx00n3j2dCT5eU0DUKxUm1-elhu60A-BvlZkf_IJn7Mo0Hvmt7rVPf_lPK16RBfEmEa_RuouMREyZgUZLDLBgub1TWHZ_wd6bi/s1600/MotoPiduino_lm35_3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVYvpU3VXmoU9mUc7i1pjmeaUhRFk8jBAeKp8xQgGt4jOx00n3j2dCT5eU0DUKxUm1-elhu60A-BvlZkf_IJn7Mo0Hvmt7rVPf_lPK16RBfEmEa_RuouMREyZgUZLDLBgub1TWHZ_wd6bi/s1600/MotoPiduino_lm35_3.jpg" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGBhGAOLyAXpySqO5efWfoHew1IWf_iK_IftW-8XnccPgElJ4nUGgiRmfVHK3M-dZAVyG8qXUcYESOV5etFt5xVLQKK_xuuUtmEkpy0CwNpK1OFOOCipOyJEiupfv1l4eTdnNM9BNs8H4O/s1600/motopiduino_lm35_4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGBhGAOLyAXpySqO5efWfoHew1IWf_iK_IftW-8XnccPgElJ4nUGgiRmfVHK3M-dZAVyG8qXUcYESOV5etFt5xVLQKK_xuuUtmEkpy0CwNpK1OFOOCipOyJEiupfv1l4eTdnNM9BNs8H4O/s1600/motopiduino_lm35_4.JPG" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
四. I2C Library 軟體下載點:<br />
1. 下載 ADS1015 (I2C) Library : <a href="https://github.com/m3m0ry/Adafruit-Raspberry-Pi-Python-Code">https://github.com/m3m0ry/Adafruit-Raspberry-Pi-Python-Code</a><br />
2. 編寫Python LM35 程式 motopiduino_lm35.py 如下(請該檔案建立在adafruit_ADS1x15目錄下)<br />
<br />
#!/usr/bin/python<br />
import time, signal, sys<br />
from Adafruit_ADS1x15 import ADS1x15<br />
<br />
def signal_handler(signal, frame):<br />
print 'You pressed Ctrl+C!'<br />
sys.exit(0)<br />
signal.signal(signal.SIGINT, signal_handler)<br />
#print 'Press Ctrl+C to exit'<br />
<br />
ADS1015 = 0x00 # 12-bit ADC<br />
<br />
# Select the gain<br />
gain = 6144 # +/- 6.144V<br />
#gain = 4096 # +/- 4.096V<br />
<br />
# Select the sample rate<br />
sps = 250 # 250 samples per second<br />
<br />
# Initialise the ADC using the default mode (use default I2C address)<br />
# Set this to ADS1015 depending on the ADC you are using!<br />
adc = ADS1x15(ic=ADS1015)<br />
<br />
while(True):<br />
# Read channel 0 in single-ended mode using the settings above<br />
volts = adc.readADCSingleEnded(0, gain, sps)<br />
# 10mv per degree<br />
lm35_c = ((volts/ 10.0)-1.5)<br />
# To read channel 3 in single-ended mode, +/- 1.024V, 860 sps use:<br />
# volts = adc.readADCSingleEnded(3, 1024, 860)<br />
<br />
print "%.6f" % (lm35_c)<br />
time.sleep(1);<br />
<div>
<br /></div>
<br />
五. 執行:<br />
$ sudo python motopiduino_lm35.py<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_yghDFzGEW6KQZwdY0i1uDJKqHeB2F-X3QW2feT-weSfpuVpyPzNcnx7F_CYqICL59v9sB5hE07LPFNhOkaeMhyphenhyphenI4wQsrI8KpaxradarGgGinBLST96z1Yfgf1I6B_3UbatCb7fL6yHJt/s1600/motopiduino_lm35_command.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_yghDFzGEW6KQZwdY0i1uDJKqHeB2F-X3QW2feT-weSfpuVpyPzNcnx7F_CYqICL59v9sB5hE07LPFNhOkaeMhyphenhyphenI4wQsrI8KpaxradarGgGinBLST96z1Yfgf1I6B_3UbatCb7fL6yHJt/s1600/motopiduino_lm35_command.JPG" height="239" width="320" /></a></div>
<br />
<br />
Informatiom: <a href="http://motoduino.com/">http://motoduino.com</a><br />
<br />
<br />
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-28734517836452594462014-03-15T15:55:00.001+08:002014-03-15T16:54:15.503+08:00新開發 Arduino 感測器(Terminal)介紹<div dir="ltr" style="text-align: left;" trbidi="on">
最近開發了一些Arduino感測器及周邊套件可以直接接到 Arduino S4A IO Board / S4A Sensor Board:<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4yp5xewMh4vuRos4IkdE2VoWXfreFHfkg9XEutWXsdR0tiSZ0ComHD5KhaVpwKfgVZ6PrJPWkK4RrfZ3xqZ7VCM0OD6q2r9ZB4Sv-eFGGEF2hpm55a5KEzzmm6D1HF1RG6cLJRDYXjYqA/s1600/Terminals.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4yp5xewMh4vuRos4IkdE2VoWXfreFHfkg9XEutWXsdR0tiSZ0ComHD5KhaVpwKfgVZ6PrJPWkK4RrfZ3xqZ7VCM0OD6q2r9ZB4Sv-eFGGEF2hpm55a5KEzzmm6D1HF1RG6cLJRDYXjYqA/s1600/Terminals.jpg" height="239" width="320" /></a></div>
<br />
<br />
<br />
1. 按鈕開關: (數位訊號)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrluhh2SMPTUAZcfZDL_7JR_sb4n5ptT5YuFGEMWFO2Rj9X2y1Pu-fhVIKcisV2uRxMEdjLzOzKVPBchejwrx6F0eu4s2z8LC-tjorOqsIFxo_Yl7CBStBTkBrUKRzKqdXNjjG_yiZtL18/s1600/buttonSample.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrluhh2SMPTUAZcfZDL_7JR_sb4n5ptT5YuFGEMWFO2Rj9X2y1Pu-fhVIKcisV2uRxMEdjLzOzKVPBchejwrx6F0eu4s2z8LC-tjorOqsIFxo_Yl7CBStBTkBrUKRzKqdXNjjG_yiZtL18/s1600/buttonSample.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
2. 紅色 LED 輸出元件: (數位訊號) </div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggfkOnSNf1a5mLVN8x77BtE_w_rnvs7d4RljmZBcLFxwqGC9cphQijaPKlmLRrlI8S1a-C7Zofu0hBGSbs-ewozKOiWcPhqaIkAOu15LIFG1pFKYYFkYjUF0JoeQCW5PultGkIk2_lA4Ji/s1600/LEDSample.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggfkOnSNf1a5mLVN8x77BtE_w_rnvs7d4RljmZBcLFxwqGC9cphQijaPKlmLRrlI8S1a-C7Zofu0hBGSbs-ewozKOiWcPhqaIkAOu15LIFG1pFKYYFkYjUF0JoeQCW5PultGkIk2_lA4Ji/s1600/LEDSample.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
3. 光感測元件(光敏電阻): (類比訊號)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR04wkksMgN7BlplmqmXJjShxaJ1VrPCfn2Oe5G34zhQPmECPHcTCKdhmFsBVyrP_P8fXuIPoPHqP9vfDHgvGV72iHKDoW3Bq8vfr2BVhmJcybwTjbNrINnRfrrM6QfdODh4ZbmjxTjrVc/s1600/CDS.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR04wkksMgN7BlplmqmXJjShxaJ1VrPCfn2Oe5G34zhQPmECPHcTCKdhmFsBVyrP_P8fXuIPoPHqP9vfDHgvGV72iHKDoW3Bq8vfr2BVhmJcybwTjbNrINnRfrrM6QfdODh4ZbmjxTjrVc/s1600/CDS.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
4. OH49E 霍爾感測器: (類比訊號)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2Wa-5bINfkkLMwPJrGVSAgiC1HHriRcc8I40DXLEs9l4PowNWLwqfw9Qd4ZdbrSrqx7VF5YTL5cRKCWDzegpTtUJ1OosKFrH4OTypWgEYzyeFpcSCbPGUi8y8_zCPmQasWDeK2ie34CJ/s1600/IMG_20140315_101505.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2Wa-5bINfkkLMwPJrGVSAgiC1HHriRcc8I40DXLEs9l4PowNWLwqfw9Qd4ZdbrSrqx7VF5YTL5cRKCWDzegpTtUJ1OosKFrH4OTypWgEYzyeFpcSCbPGUi8y8_zCPmQasWDeK2ie34CJ/s1600/IMG_20140315_101505.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
5. DHT11 溫濕感測器 : (數位訊號)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOcwpgihFaBYMoBdr4ZN-okhxUqRmoPEjKUhvFhbq8KoCjlVBOTjqtn38cxTXHNF6EFfc1hHy6hx4_VFI9-WC88Wk419z772x40pBSQF40vhrMBXTrzTfWzRfJBp67qWoYB-1dH8HP19Tl/s1600/DHT11.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOcwpgihFaBYMoBdr4ZN-okhxUqRmoPEjKUhvFhbq8KoCjlVBOTjqtn38cxTXHNF6EFfc1hHy6hx4_VFI9-WC88Wk419z772x40pBSQF40vhrMBXTrzTfWzRfJBp67qWoYB-1dH8HP19Tl/s1600/DHT11.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
6. DS18B20 水溫感測器: (類比訊號)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgtiWww9810fRUWtb6OnIPDLK8R3kwQe6QazvtxHCMA0ENJIo36g-3I3Ysu5ApJ8GQMFVLhEFTT6iyyHX5A4Q8N11n9OdaQQ66oQYW2BuDI67LcD8sHwejNXRIYys21KpsDYRPcVIb_7Gc/s1600/DS18B20.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgtiWww9810fRUWtb6OnIPDLK8R3kwQe6QazvtxHCMA0ENJIo36g-3I3Ysu5ApJ8GQMFVLhEFTT6iyyHX5A4Q8N11n9OdaQQ66oQYW2BuDI67LcD8sHwejNXRIYys21KpsDYRPcVIb_7Gc/s1600/DS18B20.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi64uXwh2Yq43tBRk2yTZjT2nW3htE7unNvizm_9QdOX55vv1RJDcuGfIVEyGt_AAAbDvUL8IOr6fnuisg7CCny9FwPuCH7BBntiFBN_ARdQYix1eiGEODeRPau6qmK8NcM8_VM7nRD-ZYU/s1600/IGP1391.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi64uXwh2Yq43tBRk2yTZjT2nW3htE7unNvizm_9QdOX55vv1RJDcuGfIVEyGt_AAAbDvUL8IOr6fnuisg7CCny9FwPuCH7BBntiFBN_ARdQYix1eiGEODeRPau6qmK8NcM8_VM7nRD-ZYU/s1600/IGP1391.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
7. 微動開關 : (數位訊號)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgioqsu_68fNtmAYS3jlFf-JHOMumWOUY6BGhil5vYDeP0TFiHbXWJ8WQ7eMv4-URLMx5bu0GNJhsUQZYJqCOlB5E9JfgqyyqVvkFiLZ9TGrLF2bpqWsUWWfZ0FaoX0ExTe6CZDmW-tcscM/s1600/MicroSwitchSample.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgioqsu_68fNtmAYS3jlFf-JHOMumWOUY6BGhil5vYDeP0TFiHbXWJ8WQ7eMv4-URLMx5bu0GNJhsUQZYJqCOlB5E9JfgqyyqVvkFiLZ9TGrLF2bpqWsUWWfZ0FaoX0ExTe6CZDmW-tcscM/s1600/MicroSwitchSample.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
8. PIR 人體紅外線感測器: (數位訊號)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizYjjiNO0oXrL1KTZiScmTxCKHBld4y3cToDJavfhMNpnno2sU4HOQRvKINNynPXCsZOcXA5LV63m3yaupfkx4K8ZZDilZxAcWJZZOzUI_P6a5bQHx_C1U8_ANdtaAbK_W3jFVa8iQFYsC/s1600/PIR.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizYjjiNO0oXrL1KTZiScmTxCKHBld4y3cToDJavfhMNpnno2sU4HOQRvKINNynPXCsZOcXA5LV63m3yaupfkx4K8ZZDilZxAcWJZZOzUI_P6a5bQHx_C1U8_ANdtaAbK_W3jFVa8iQFYsC/s1600/PIR.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com2tag:blogger.com,1999:blog-9207523769553422691.post-6514527485297865302014-01-25T20:03:00.001+08:002014-02-02T22:28:52.383+08:00S4A IO Board/Shield for Arduino 詳細介紹<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt;">一.簡介</span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt;"> S4A
IO Board/shield</span><span style="font-family: 標楷體; font-size: 14.0pt;">主要設計給<span lang="EN-US">Arduino</span>或<span lang="EN-US">S4A</span>初學者使用的一塊擴充板,除了支持一般杜邦接頭<span lang="EN-US">3 pin</span>腳位外還可以連接<span lang="EN-US">10</span>組<span lang="EN-US">RJ11</span>的接頭<span lang="EN-US">(</span>五組數位及五組類比<span lang="EN-US">)</span>感測元件<span lang="EN-US">(</span>另購<span lang="EN-US">)</span>,如溫濕度感測器、土壤濕度感測器等。另外預留一個藍芽孔位給需要無線傳輸的使用者,可利用此無線傳輸跟<span lang="EN-US">Android</span>手機或電腦溝通。此外也提供外部電源切換。此擴充板相容於<span lang="EN-US">Arduino Duemilanove </span>、<span lang="EN-US">UNO</span>、<span lang="EN-US">Leonado</span>。<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTgd5jhlS4sEfOq0m-qw2McgfleNHvG8fTe3CFIMPA2wEMYNfDWlR3rzlCjJ9LJd29nSEpTlcEpqsXGdPUJCgRC4LRDsP-xqvRJJuYjpE5imREFi-95FoE7XL0Z1029d4sWrwaFceR3WZb/s1600/IOwithUNO.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTgd5jhlS4sEfOq0m-qw2McgfleNHvG8fTe3CFIMPA2wEMYNfDWlR3rzlCjJ9LJd29nSEpTlcEpqsXGdPUJCgRC4LRDsP-xqvRJJuYjpE5imREFi-95FoE7XL0Z1029d4sWrwaFceR3WZb/s1600/IOwithUNO.png" height="158" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuvFhi7lCM11YiHxU8PhfELT6YV8LEAKxUWBCfRcl6QGQklyPcM2ePvuhXt7YfmDg84j0dDryUnRi64oabD0RFVmxHAyXf4tDGcVLkfHWof5XGrFEIxAtvi2fqoHzuS5j3huwSoN0zrbf_/s1600/IOBoardonUNO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuvFhi7lCM11YiHxU8PhfELT6YV8LEAKxUWBCfRcl6QGQklyPcM2ePvuhXt7YfmDg84j0dDryUnRi64oabD0RFVmxHAyXf4tDGcVLkfHWof5XGrFEIxAtvi2fqoHzuS5j3huwSoN0zrbf_/s1600/IOBoardonUNO.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 標楷體; font-size: 14.0pt;">二.</span><b style="text-indent: -18pt;"><span lang="EN-US" style="font-family: 標楷體; font-size: 16.0pt; mso-bidi-font-family: 標楷體;"><span style="font-family: 'Times New Roman'; font-size: 7pt; font-weight: normal;"> </span></span></b><b style="text-indent: -18pt;"><span style="font-family: 標楷體; font-size: 16.0pt;">內容說明及特點<span lang="EN-US">:</span></span></b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh5hLqsxRw8rG3ygsXPgTkSCLdcGzTNk4WlMGRHdzQahBFDPWpb7lwlP1o1ESuf7EHXw6UAPGL5qBgctTdf03KhuKAeKK3d4lOch3KbAl_5EMhjBypDG27Uw9IQLhyQj6tHVlAUU2uQpKk/s1600/S4A_IO.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh5hLqsxRw8rG3ygsXPgTkSCLdcGzTNk4WlMGRHdzQahBFDPWpb7lwlP1o1ESuf7EHXw6UAPGL5qBgctTdf03KhuKAeKK3d4lOch3KbAl_5EMhjBypDG27Uw9IQLhyQj6tHVlAUU2uQpKk/s1600/S4A_IO.png" height="240" width="320" /></a></div>
<b style="text-indent: -18pt;"><span style="font-family: 標楷體; font-size: 16.0pt;"><span lang="EN-US"><br /></span></span></b></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b><span style="font-family: 標楷體; font-size: 16.0pt;"><span lang="EN-US"><o:p></o:p></span></span></b></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: 標楷體; font-size: 14.0pt;">特點<span lang="EN-US">:<o:p></o:p></span></span></b></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt; mso-bidi-font-family: 標楷體;">1.<span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span></span><!--[endif]--><span style="font-family: 標楷體; font-size: 14.0pt;">五組<span lang="EN-US">RJ11(6P4C</span>電話線<span lang="EN-US">)</span>數位接頭及五組類比接頭容易外接其他裝置或感測器,可以連接至少<span lang="EN-US">10</span>公尺長距離的終端感測器或裝置<span lang="EN-US">(</span>另購<span lang="EN-US">)</span>。<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt; mso-bidi-font-family: 標楷體;">2.<span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span></span><!--[endif]--><span style="font-family: 標楷體; font-size: 14.0pt;">電源紅色<span lang="EN-US">LED</span>。<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt; mso-bidi-font-family: 標楷體;">3.<span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span></span><!--[endif]--><span style="font-family: 標楷體; font-size: 14.0pt;">一顆 綠色<span lang="EN-US">LED </span>連接<span lang="EN-US">D13</span>腳位<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt; mso-bidi-font-family: 標楷體;">4.<span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span></span><!--[endif]--><span style="font-family: 標楷體; font-size: 14.0pt;">預留一個藍芽孔位<span lang="EN-US">(UART)<o:p></o:p></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt; mso-bidi-font-family: 標楷體;">5.<span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span></span><!--[endif]--><span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt;">Jumper</span><span style="font-family: 標楷體; font-size: 14.0pt;">可切換<span lang="EN-US">Vcc</span>為內部電源(5V)或外部電源供給。<span lang="EN-US"><o:p></o:p></span></span></div>
<div class="MsoNormal">
</div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-para-margin-left: 0gd;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-para-margin-left: 0gd;">
<span lang="EN-US" style="font-family: 標楷體;"><br /></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b><span lang="EN-US" style="font-family: 標楷體; font-size: 16.0pt;">三. RJ11(6P4C</span></b><b><span style="font-family: 標楷體; font-size: 16.0pt;">電話線<span lang="EN-US">)</span>接頭腳位說明<span lang="EN-US"><o:p></o:p></span></span></b></div>
<div class="MsoNormal" style="mso-char-indent-count: 1.5; text-indent: 21.0pt;">
<span lang="EN-US" style="font-family: 標楷體; font-size: 14.0pt;">RJ11</span><span style="font-family: 標楷體; font-size: 14.0pt;">接頭中其中兩接腳為<span lang="EN-US">VCC</span>及<span lang="EN-US">GND</span>,另外兩根接腳為<span lang="EN-US">IO</span>訊號接腳,也就是說連接<span lang="EN-US">RJ11</span>的感測元件可以利用此兩根<span lang="EN-US">IO</span>溝通訊號,例如<span lang="EN-US">I2C</span>訊號就可以利用<span lang="EN-US">A4</span>、<span lang="EN-US">A5</span>那個孔位連接裝置。</span></div>
<div class="MsoNormal" style="mso-char-indent-count: 1.5; text-indent: 21.0pt;">
<span style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0S7rgZX0L4SzJAdVtItzsVdCWwg4msxBRKopxUV-qvor_OeaGlYWr-8TUdURFrNyApQUd0SDxwx7T658-bydxFV2m9rEfBEN8JOFQFlFVP6wXZg6RPg2Mf8YuEA0dE6IuAZScisjkDlm6/s1600/S4A_IO_Devices.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0S7rgZX0L4SzJAdVtItzsVdCWwg4msxBRKopxUV-qvor_OeaGlYWr-8TUdURFrNyApQUd0SDxwx7T658-bydxFV2m9rEfBEN8JOFQFlFVP6wXZg6RPg2Mf8YuEA0dE6IuAZScisjkDlm6/s1600/S4A_IO_Devices.jpg" height="239" width="320" /></a></div>
<div class="MsoNormal" style="mso-char-indent-count: 1.5; text-indent: 21.0pt;">
<span style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b><span style="font-family: 標楷體; font-size: 16.0pt;">四. 安裝藍芽模組說明<span lang="EN-US"><o:p></o:p></span></span></b></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b><span style="font-family: 標楷體; font-size: 16.0pt;"> </span></b><b style="font-family: 標楷體; font-size: 21px; text-indent: -18pt;"> </b></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="font-family: 標楷體; font-size: 21px; text-indent: -18pt;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7pHOZNPPbegq1TnPSu02UuoKhsoVDCd6q-QjR4ugcQte5FSTVpxqog9V0hdgJUSlAK-JLz3qkMDXD3ScEwCwStAy1p0XgodselwtvKYIBie9cqCso_x-LLchaV6FqhFXZP5vvOEbck9wV/s1600/Bluetooth.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7pHOZNPPbegq1TnPSu02UuoKhsoVDCd6q-QjR4ugcQte5FSTVpxqog9V0hdgJUSlAK-JLz3qkMDXD3ScEwCwStAy1p0XgodselwtvKYIBie9cqCso_x-LLchaV6FqhFXZP5vvOEbck9wV/s1600/Bluetooth.jpg" height="116" width="320" /></a></b></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="font-family: 標楷體; font-size: 21px; text-indent: -18pt;"><br /></b></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="font-family: 標楷體; font-size: 21px; text-indent: -18pt;"><br /></b></div>
<br />
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b style="font-family: 標楷體; font-size: 21px; text-indent: -18pt;"> </b></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b><span style="font-family: 標楷體; font-size: 16.0pt;"></span></b></div>
<div class="separator" style="clear: both; text-align: center;">
<b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnZSFzCEHkESbKAR_rujPFeF3tg7aveNlys7JPcbP1RkJ6tQZZN_F2ibispX99S-heLhDghftPM80fOG-2dSYKqefBtONpyfjWhZBCq-Va1crMS9PttXPkWUhyphenhyphenklnYKTUt8Yx7pLhKIjgm/s1600/IOonUNonBT.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnZSFzCEHkESbKAR_rujPFeF3tg7aveNlys7JPcbP1RkJ6tQZZN_F2ibispX99S-heLhDghftPM80fOG-2dSYKqefBtONpyfjWhZBCq-Va1crMS9PttXPkWUhyphenhyphenklnYKTUt8Yx7pLhKIjgm/s1600/IOonUNonBT.png" height="236" width="320" /></a></b></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: red; font-family: 標楷體;">#### </span></b><b><span style="color: red; font-family: 標楷體;">請注意安裝藍芽模組腳位一定要正確對應<span lang="EN-US">IO Board</span>上的藍芽預留孔位<span lang="EN-US">###</span></span></b><b><span lang="EN-US" style="font-family: 標楷體;"><o:p></o:p></span></b></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<b><span style="font-family: 標楷體; font-size: 16.0pt;"><br /></span></b></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<span style="font-family: 標楷體;"><span style="font-size: 21px;"><b>參考網站: <a href="http://motoduino.com/">http://motoduino.com</a></b></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-para-margin-left: 0gd; text-indent: -18.0pt;">
<span style="font-family: 標楷體;"><span style="font-size: 21px;"><b><br /></b></span></span></div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-para-margin-left: 0gd;">
</div>
<div class="MsoListParagraph" style="margin-left: 18.0pt; mso-para-margin-left: 0gd;">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 標楷體; font-size: 14.0pt;"><br /></span></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com1tag:blogger.com,1999:blog-9207523769553422691.post-78594363274213413692014-01-05T20:19:00.001+08:002014-07-13T22:06:34.910+08:00Raspberry (樹莓派) 與 Arduino Shield 橋梁: MotoPiduino 介紹及I2C檢測<div dir="ltr" style="text-align: left;" trbidi="on">
此塊<a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a>的功能之前大概說明過,這次說明一下IO 腳位的用途及對應Raspberry Pi的腳位.<br />
從下圖板子可以看出有兩排腳位,此腳位剛好可以對應Arduino 腳位, 相容於Arduino UNO/Deumilanove. 也可以接兩顆DC馬達.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9z5FTxVKIYBoCHrt3PIV7scP9rZ6c0m-MxQlHCqQRAk6CnkTLwivoIvp92rRwXmBaZwFX0SePaxp3NyZHPENIS1HR_OkA2KQtmCf7HUFtNdOnKBs63rxdMg_anDB0g59pnrVpkU-UpllS/s1600/motopiduino_%E8%85%B3%E4%BD%8D%E8%AA%AA%E6%98%8E.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9z5FTxVKIYBoCHrt3PIV7scP9rZ6c0m-MxQlHCqQRAk6CnkTLwivoIvp92rRwXmBaZwFX0SePaxp3NyZHPENIS1HR_OkA2KQtmCf7HUFtNdOnKBs63rxdMg_anDB0g59pnrVpkU-UpllS/s320/motopiduino_%E8%85%B3%E4%BD%8D%E8%AA%AA%E6%98%8E.jpg" height="232" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
下圖是使用MotoPiduino時, Raspberry Pi 跟 Arduino腳位的對應. 可以看出都是Digital Pin腳位對應Raspberry Pi, 只有 A4及A5對應到Raspberry GPIO02 GPIO03, 主要是I2C 控制IO. 所以可以把以前接Arduino的 I2C 周邊接到此處(A4/A5). </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0UvmH8sOefaeVchp5d988Z1AJP86o5FdjYapOexazBCNO9zeMVh_bGiSlJtFO26ZJ8Q_lUAHS2sFTGxB76sWhiFSUYZOLahn3VAzwKod4PEw1TK-6xRNewDpAYA8XmtLABEY-VFBJU2mh/s1600/MotoPiduino_Pin_Map.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0UvmH8sOefaeVchp5d988Z1AJP86o5FdjYapOexazBCNO9zeMVh_bGiSlJtFO26ZJ8Q_lUAHS2sFTGxB76sWhiFSUYZOLahn3VAzwKod4PEw1TK-6xRNewDpAYA8XmtLABEY-VFBJU2mh/s320/MotoPiduino_Pin_Map.jpg" height="213" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
接下來說明如何 enable raspberry Pi 的 I2C 功能. 把MotoPiduino連接到Raspberry Pi後,如下圖.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM_5T_0ECqvkdX7UkmaJyAxrJds3tUjBpDBdnTHPqrkK8LCv_Kb94iAG0z-_amLC1V5zdEslxqL6SsB_Bkfyh9yfgoRy9Lm1nACuvq2Xee7vvQfajPt8fw6ftdg4c2lzd3NsnKW6NCK_AW/s1600/Pi_motopiduino.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM_5T_0ECqvkdX7UkmaJyAxrJds3tUjBpDBdnTHPqrkK8LCv_Kb94iAG0z-_amLC1V5zdEslxqL6SsB_Bkfyh9yfgoRy9Lm1nACuvq2Xee7vvQfajPt8fw6ftdg4c2lzd3NsnKW6NCK_AW/s320/Pi_motopiduino.jpg" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">sudo</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span><span style="font-family: 微軟正黑體; font-size: 18pt;">nano</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
/etc/modules</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">#</span><span style="font-family: 微軟正黑體; font-size: 18pt;">加入底下兩行</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">i2c-bcm2708</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">i2c-dev</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">#</span><span style="font-family: 微軟正黑體; font-size: 18pt;">安裝</span><span style="font-family: 微軟正黑體; font-size: 18pt;">I2C
tools</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">sudo</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
apt-get install python-</span><span style="font-family: 微軟正黑體; font-size: 18pt;">smbus</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">sudo</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
apt-get install i2c-tools</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">#</span><span style="font-family: 微軟正黑體; font-size: 18pt;">修改</span><span style="font-family: 微軟正黑體; font-size: 18pt;">raspi-blacklist.conf</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">sudo</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span><span style="font-family: 微軟正黑體; font-size: 18pt;">nano</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
/etc/</span><span style="font-family: 微軟正黑體; font-size: 18pt;">modprobe.d</span><span style="font-family: 微軟正黑體; font-size: 18pt;">/</span><span style="font-family: 微軟正黑體; font-size: 18pt;">raspi-blacklist.conf</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">#blacklist
spi-bcm2708 </span><span style="font-family: Wingdings; font-size: 18pt;">ß</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span><span style="font-family: 微軟正黑體; font-size: 18pt;">前面加個
</span><span style="font-family: 微軟正黑體; font-size: 18pt;">#</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">#blacklist
i2c-bcm2708 </span><span style="font-family: Wingdings; font-size: 18pt;">ß</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span><span style="font-family: 微軟正黑體; font-size: 18pt;">前面加個
</span><span style="font-family: 微軟正黑體; font-size: 18pt;">#</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">#Check</span><span style="font-family: 微軟正黑體; font-size: 18pt;">連接的裝置</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
</span></div>
<div class="separator" style="clear: both;">
</div>
<div style="direction: ltr; margin-bottom: 0pt; margin-top: 0pt; unicode-bidi: embed; vertical-align: baseline;">
<span style="font-family: 微軟正黑體; font-size: 18pt;">sudo</span><span style="font-family: 微軟正黑體; font-size: 18pt;">
i2cdetect -y 1</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMjbDLys4r7u5_Me7arFv7e2vq3xRdb7jLLeIrvhfYtEd1ONwiwF3pYJRObFPlz0Vp8UaCkIX9cc1jnUcp_fohJDNP-t48hrmgUQfxpBtUohSRJE_0zzW0kAiBzpsVUqsBefhaVj_-phKc/s1600/i2cdetect.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMjbDLys4r7u5_Me7arFv7e2vq3xRdb7jLLeIrvhfYtEd1ONwiwF3pYJRObFPlz0Vp8UaCkIX9cc1jnUcp_fohJDNP-t48hrmgUQfxpBtUohSRJE_0zzW0kAiBzpsVUqsBefhaVj_-phKc/s320/i2cdetect.jpg" height="317" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
看到顯示48表示MotoPiduino上的 I2C address為 48(16進制) 處於溝通狀態. 接下來試試疊上一個Arduino Proto Shield, 在Proto Shield上有一個I2C介面重力加速度計及陀螺儀 (9DOF), Data Pin接到A4及A5. 如下圖.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgxISahVGzqAIIsap949Yi5ft2ogZ-z5_dYGOHwvTAKrYXrPaw4E2CGtt2ainJmhL4Ry2o-V1hCJeaJDvullz_54G0DazImnJrmTzzuDKHhAJBWIrKNV61X5WAG4mx0Jk0ZlpANArqHj7k/s1600/9DOF_I2C.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgxISahVGzqAIIsap949Yi5ft2ogZ-z5_dYGOHwvTAKrYXrPaw4E2CGtt2ainJmhL4Ry2o-V1hCJeaJDvullz_54G0DazImnJrmTzzuDKHhAJBWIrKNV61X5WAG4mx0Jk0ZlpANArqHj7k/s320/9DOF_I2C.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
在試著在command line下 sudo i2cdetect -y 1 則可以看到顯示 53數字, 表示偵測到9DOF的裝置(I2C address為 0x53).</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAsPZbHElmyLtRE0m9HFp7n7xOhAtnmSbgeyrjbSbGA524RT4x5EYNdyX_pRTXBRQN04dT_FmO2qSG8L7mocI6Mfm_kEELbYIc8hlZk4ztde4EJnpTNJs02Q_4VdJtaAi5ooUqPRrTus4v/s1600/9DOF_i2cdetect.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAsPZbHElmyLtRE0m9HFp7n7xOhAtnmSbgeyrjbSbGA524RT4x5EYNdyX_pRTXBRQN04dT_FmO2qSG8L7mocI6Mfm_kEELbYIc8hlZk4ztde4EJnpTNJs02Q_4VdJtaAi5ooUqPRrTus4v/s320/9DOF_i2cdetect.jpg" height="302" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
#下一次再來說明接I2C LED 七段顯示器如何顯示數字,如下圖!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1Op1Kilglx6nQl6RxmLkKRNXWNBOnr4yFBCD-lBc877Ta31gZnQ24qajPxOuVJLkN_ZAjJMTQ6gzL6WK-mkNIc12sk1SiJ6t-dOCEuus8nEne39N4_EenM5ZIVqwuINtqVtimA5GMXZkF/s1600/i2c_led2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1Op1Kilglx6nQl6RxmLkKRNXWNBOnr4yFBCD-lBc877Ta31gZnQ24qajPxOuVJLkN_ZAjJMTQ6gzL6WK-mkNIc12sk1SiJ6t-dOCEuus8nEne39N4_EenM5ZIVqwuINtqVtimA5GMXZkF/s320/i2c_led2.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Data: <a href="http://motoduino.com/">http://motoduino.com</a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-22342290358174730072013-09-20T22:57:00.000+08:002014-07-13T22:06:57.965+08:00樹莓派(Raspberry Pi)手機遙控車(Part 1) = MotoPiduino + Raspberry Pi (樹莓派) + USB WiFi dongle <div dir="ltr" style="text-align: left;" trbidi="on">
最近開發的<a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a>持續改良修正問題,目前MotoPiduino搭配Raspberry Pi測試已告一段落,預計下個月應該可以上市! MotoPiduino主要是搭起Raspberry Pi跟Arduino之間的橋樑,可以把Arduino的擴充板直接插在MotoPiduino上作運用,除此,MotoPiduino還有內建馬達驅動IC,可以直接驅動兩顆DC直流馬達. 此影片範例即是利用Android手機遙控Raspberry Pi來控制馬達運轉! 在Part 2中將接上Raspberry Pi專用的攝影模組,可以即時傳輸影像(這是Arduino所辦不到), 敬請期待!!<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6Cjmxy6SS6oxbj6Zgtnj6139mwV3UN-A5xlqPVycc3AiDb6nur8Y9ox4WymqFLiwUU5XGoYKxUx-MGl3jWEBLoBjL03y5MNf7TOCbfApdq8NGN_P_rI19_mxMsEIxAB46NZ_QltrCgXy/s1600/pi_robot_1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6Cjmxy6SS6oxbj6Zgtnj6139mwV3UN-A5xlqPVycc3AiDb6nur8Y9ox4WymqFLiwUU5XGoYKxUx-MGl3jWEBLoBjL03y5MNf7TOCbfApdq8NGN_P_rI19_mxMsEIxAB46NZ_QltrCgXy/s1600/pi_robot_1.JPG" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHY8QfACcQvEIt4XX66Mc1ve3ApxXp2dbFQ63Te1Fyjdgdd_VDGw77berXwtT9t9vjzf3SPoTBUwUulGmWbg-MhGeU1r9kZOuNeWK0kLGoFeLIlclbrvqoVEjhBK2blnlvSZjOAJgIUGZ/s1600/Pi_Robot_2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHY8QfACcQvEIt4XX66Mc1ve3ApxXp2dbFQ63Te1Fyjdgdd_VDGw77berXwtT9t9vjzf3SPoTBUwUulGmWbg-MhGeU1r9kZOuNeWK0kLGoFeLIlclbrvqoVEjhBK2blnlvSZjOAJgIUGZ/s1600/Pi_Robot_2.JPG" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5YZ9ow5ea7oSbTHVV9hR6EHrj3qjFpyZbgiqX5a515UyD3WXOADxkcVk7ltDsT9yEIoAKPVrAkZXgPfjgEJjhHYsiXH8eEMDh6aSUAsBIg4zhU_hRAwottvrv9prsrQ-gPY6XLsBmTeS7/s1600/pi_robot_lcd.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5YZ9ow5ea7oSbTHVV9hR6EHrj3qjFpyZbgiqX5a515UyD3WXOADxkcVk7ltDsT9yEIoAKPVrAkZXgPfjgEJjhHYsiXH8eEMDh6aSUAsBIg4zhU_hRAwottvrv9prsrQ-gPY6XLsBmTeS7/s1600/pi_robot_lcd.JPG" height="239" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
使用材料:<br />
1. Raspberry Pi<br />
2. <a href="http://goods.ruten.com.tw/item/show?21404305766828" target="_blank">MotoPiduino</a><br />
3. 5V 行動電源<br />
4. 9V 電池 (驅動馬達)<br />
5. USB WiFi Dongle<br />
6. 圓形車體<br />
<br />
遙控車程式(Python):<br />
<br />
----------------------------------------------------<br />
#Get the GPIO module<br />
import RPi.GPIO as GPIO<br />
#Get the time module<br />
import time<br />
#Get the socket module<br />
import socket<br />
#Some IP constants for this, the server<br />
UDP_IP = "192.168.0.113" <span style="color: red;"> // 請修改成自己的 IP Address</span><br />
UDP_PORT= 8888 // <span style="color: red;">default port : 8888</span><br />
#A routine to control a pair of pins<br />
def ControlAPairOfPins(FirstPin,FirstState,SecondPin,SecondState):<br />
print("Controlling pins")<br />
if FirstState == "1":<br />
GPIO.output(int(FirstPin),True)<br />
else:<br />
GPIO.output(int(FirstPin),False)<br />
if SecondState == "1":<br />
GPIO.output(int(SecondPin),True)<br />
else:<br />
GPIO.output(int(SecondPin),False)<br />
#Just retur<br />
return<br />
<br />
####Main body of code<br />
#Get rid of warnings<br />
GPIO.setwarnings(False)<br />
#Set the GPIO mode<br />
GPIO.setmode(GPIO.BOARD)<br />
#Set the pins to be outputs<br />
GPIO.setup(11,GPIO.OUT)<br />
GPIO.setup(12,GPIO.OUT)<br />
GPIO.setup(13,GPIO.OUT)<br />
GPIO.setup(15,GPIO.OUT)<br />
#Set up the IP related details<br />
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP<br />
sock.bind((UDP_IP, UDP_PORT))<br />
print "Pi_Robot server started ...."<br />
<br />
while True:<br />
#Wait for a UDP command to be received<br />
print("Waiting for UDP command")<br />
MyChar, addr = sock.recvfrom(1024) #buffer size is 1024<br />
print "I received: " + MyChar<br />
if MyChar == "forward":<br />
ControlAPairOfPins("12","1","13","1")<br />
ControlAPairOfPins("11","1","15","1") <br />
print "Forward"<br />
elif MyChar == "stop":<br />
ControlAPairOfPins("12","0","13","0")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ControlAPairOfPins("11","0","15","0")<br />
print "Stop"<br />
elif MyChar == "back":<br />
ControlAPairOfPins("12","1","13","0")<br />
ControlAPairOfPins("11","1","15","0")<br />
print "Back"<br />
elif MyChar == "left":<br />
ControlAPairOfPins("12","1","13","1")<br />
print "Left"<br />
elif MyChar == "right":<br />
ControlAPairOfPins("11","1","15","1")<br />
print "Right"<br />
else:<br />
print "Not a command"<br />
<div>
<br /></div>
<div>
----------------------------------------------------------------</div>
<div>
<br /></div>
<div>
Video 請看: <a href="https://www.youtube.com/watch?v=URzivDpsf44">https://www.youtube.com/watch?v=qE1r5gKrELM</a></div>
<div>
</div>
相關資訊:<br />
http://www.motoduino.com (motopiduino user guide and android app download)<br />
http://sinocgtchen.blogspot.tw/<br />
<br />
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com10tag:blogger.com,1999:blog-9207523769553422691.post-26449711321530509342013-09-11T09:17:00.001+08:002013-09-11T09:17:17.976+08:00S4A IO Board/Shield for Arduino<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">此版本增加兩顆LED,一顆紅色(power led), 一顆綠色(連接arduino Pin 13),其它維持之前版本,尺寸<u>依然是</u>5.3 x 8.7 cm,且方便接上需要的感測器或裝置叫 S4A IO board for Arduino , IO 腳位也針對S4A Scratch 設計容易使用,可以外接電源提供給伺服馬達. IO腳位可以用一般的杜邦線接頭,也可以用RJ11電話線接頭(目前正在開發許多RJ11接頭的感測器),可以取代Arduino Sensor Shield的功能, 目前板子準備量產中.............</span><br />
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzWmwwtZZWdLB6PlWZQrBeNa8Oa8yEnk9JwGRH1z7wwwdhtf9lqv9-FAauK3q8ySpKX6gt-F9zld01A6WfLHl6rBJhjl0bSDtnoU4pJTKqtAMAsm1GOM3l4_UV8QzZYnub-aQ6sW2ZXvfL/s1600/S4A_IO_Board.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzWmwwtZZWdLB6PlWZQrBeNa8Oa8yEnk9JwGRH1z7wwwdhtf9lqv9-FAauK3q8ySpKX6gt-F9zld01A6WfLHl6rBJhjl0bSDtnoU4pJTKqtAMAsm1GOM3l4_UV8QzZYnub-aQ6sW2ZXvfL/s320/S4A_IO_Board.jpg" width="320" /></a></div>
<span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"><br /></span></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-8593851019083881732013-08-09T15:49:00.001+08:002014-01-09T18:43:53.311+08:00S4A IO Board for Arduino<div dir="ltr" style="text-align: left;" trbidi="on">
一些使用者反應 S4A Sensor Board (圖一)尺寸太大,且上面一些感測元件用不到,最近開發出一塊尺寸小(5.3 x 8.7 cm)且方便接上需要的感測器或裝置叫 S4A IO board for Arduino (圖二), IO 腳位也針對S4A Scratch 設計容易使用,可以外接電源提供給伺服馬達. 目前板子測試中.............<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2E2lWSxEnW2_nCJ2JrRPq6ylznp4EB5bKYSYtJ7F51hDhKYeBJG23p19OGFTHLXncxst-rCQBOjDYWGOuHsANXSVMrvtVwMdUKOKZ84SLn_NTBxfj_uNbFBkC43qG4wpNpR_Rv0-YSvxv/s1600/S4Aboard_v3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2E2lWSxEnW2_nCJ2JrRPq6ylznp4EB5bKYSYtJ7F51hDhKYeBJG23p19OGFTHLXncxst-rCQBOjDYWGOuHsANXSVMrvtVwMdUKOKZ84SLn_NTBxfj_uNbFBkC43qG4wpNpR_Rv0-YSvxv/s1600/S4Aboard_v3.jpg" height="295" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh98kkLgpUFWtJjX-HqawCez7CWzusRBPttiL0LyO_ZNb0mgT5Xu3P404NWPIKYGd23ycI-HpFueXmIyqSXGwoJFvFLbB8R0BfexKDCDpspAynI7fLUDihWzjtMMpyyMRkAb7ft44fEiuuo/s1600/S4AboardDemo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh98kkLgpUFWtJjX-HqawCez7CWzusRBPttiL0LyO_ZNb0mgT5Xu3P404NWPIKYGd23ycI-HpFueXmIyqSXGwoJFvFLbB8R0BfexKDCDpspAynI7fLUDihWzjtMMpyyMRkAb7ft44fEiuuo/s320/S4AboardDemo.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
(圖一) S4A Sensor Board for Arduino</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPEKDSNic9T-pv_w_wG2rxXwClPIT_HJHdciYmLImjIpS8SQktRBV8_6NTIOKbpfsP_ttybHsCVmM0E4N0QY0tndShZAyYUL2KJDTjxOyfoMAGSpMdarna0O7nGTKO5Rl37NToBYdaHTze/s1600/S4AIOBOARD_v1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPEKDSNic9T-pv_w_wG2rxXwClPIT_HJHdciYmLImjIpS8SQktRBV8_6NTIOKbpfsP_ttybHsCVmM0E4N0QY0tndShZAyYUL2KJDTjxOyfoMAGSpMdarna0O7nGTKO5Rl37NToBYdaHTze/s1600/S4AIOBOARD_v1.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
(圖二) S4A IO Board for Arduino</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhadBPgwBNqgOrmtFl3SahcZBkzALBgVOyv2vuLPRjcm1bRA3js6TJlEAHR7ylZKqS98geIMseYOTuUFW9bBC0jF4ODNWB1vBxRjB_DLcHeht8X9VxOCtoLCC4frOFHA_Q8vvwVlMARkt9e/s1600/S4AIOBoardOnMotoduino.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhadBPgwBNqgOrmtFl3SahcZBkzALBgVOyv2vuLPRjcm1bRA3js6TJlEAHR7ylZKqS98geIMseYOTuUFW9bBC0jF4ODNWB1vBxRjB_DLcHeht8X9VxOCtoLCC4frOFHA_Q8vvwVlMARkt9e/s1600/S4AIOBoardOnMotoduino.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
(圖三) S4A IO board 疊在 motoduino 上</div>
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com1tag:blogger.com,1999:blog-9207523769553422691.post-78771131258499559762013-07-19T13:50:00.002+08:002013-08-09T15:55:02.287+08:00MotoPiduino : 搭起Raspberry Pi(樹莓派) 跟 Arduino 之間的橋梁<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: large;"><a href="http://www.motoduino.com/">Motoduino</a> Lab最近開發出一塊Raspberry Pi及Arduino的轉板稱為MotoPiduino, 此塊板子目的在使Arduino及Raspberry使用者,可以很容易把Arduino Shield跟Raspberry做連結. 轉板上有一顆馬達驅動IC,可接上外部電源驅動直流馬達,很適合應用在無線遙控車的製作, 目前正在測試階段.........</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhIs87N_Wh9AW_LDZIvhkA7CCvbFwJvPXRwwqG9pXHSKKlejk6G9DXTU3Onga7HjMZUJ3l2V6BGyVoKt9mNR4WxpuuaYI3eRc50h3TJKX6Rljhq7H2IK4jnRp_XMjDw0_sEPGm6udPeAkS/s1600/motoPiduino_front_s.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhIs87N_Wh9AW_LDZIvhkA7CCvbFwJvPXRwwqG9pXHSKKlejk6G9DXTU3Onga7HjMZUJ3l2V6BGyVoKt9mNR4WxpuuaYI3eRc50h3TJKX6Rljhq7H2IK4jnRp_XMjDw0_sEPGm6udPeAkS/s1600/motoPiduino_front_s.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
MotoPiduino 正面</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9TTa5KlekoXOAyf6RRCWZx79LCxmx5pfuA-4IHLm-EBiaHnYoqt2FkJgP1Ymuxol-Fk3QSzZPXm-QO5DalWMCUYCgi8E_-Xad0op-OX4vuWU0PR0f1gFJpoS8NoRl2epx6fSJIHzO793Z/s1600/motopiduino_back_s.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9TTa5KlekoXOAyf6RRCWZx79LCxmx5pfuA-4IHLm-EBiaHnYoqt2FkJgP1Ymuxol-Fk3QSzZPXm-QO5DalWMCUYCgi8E_-Xad0op-OX4vuWU0PR0f1gFJpoS8NoRl2epx6fSJIHzO793Z/s1600/motopiduino_back_s.JPG" height="240" width="320" /></a></div>
MotoPiduino 背面<br />
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNhjgoLX8ynK0etZRefiWECbVOVr13MX29JgcJXGbWkXxtiyVVp-SjyuHnltZVjsjWO2IYPjBTQ0dQPGwljSRq6cz-02o1jZBl4TkYl2MHOnIE5xAtkMurWq3-TZ3zGp60XbmrRi85pjen/s1600/S4A_on_motopiduino_s.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNhjgoLX8ynK0etZRefiWECbVOVr13MX29JgcJXGbWkXxtiyVVp-SjyuHnltZVjsjWO2IYPjBTQ0dQPGwljSRq6cz-02o1jZBl4TkYl2MHOnIE5xAtkMurWq3-TZ3zGp60XbmrRi85pjen/s1600/S4A_on_motopiduino_s.jpg" height="240" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
S4A Sensor board疊在 MotoPiduino上</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
CTIMES 雜誌介紹:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.ctimes.com.tw/news/PrintCols.asp?O=HJX7J8RTAT2SAA00NA">http://www.ctimes.com.tw/news/PrintCols.asp?O=HJX7J8RTAT2SAA00NA</a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com0tag:blogger.com,1999:blog-9207523769553422691.post-40367077586953352922013-06-06T09:12:00.000+08:002013-06-06T09:12:30.642+08:00Android error : 在eclipse加入 library ( *.jar )經常遇到的問題,手機執行會失敗 <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
當遇到有android project有加入jar檔時, compile都沒問題,但是在手機執行時會產生某個class not found 類似錯誤訊息時, 表示有可能加入的 jar檔(如ntservice.jar 或 btservice.jar)沒有真正連結到,此時可以調整一下Project的Java Build Path-->Order and Export, 如下圖說明(以ntservice.jar為例), 把jar檔打勾或往前移至最前試著在編譯執行.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNXP1rlijfTC89cZ-zH5aTp4JayMIQQUuLmbHh1VHq1GJe0I3sM1iBIvIApUPT3rfLtqCYhG1qJzDPmyu80WsVPwPZh8YAmMOzbFYSL-neaICu3JjkEkc4iQpDI_DYvbkzkzL1IY9D2JGH/s1600/ntservice_setting.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNXP1rlijfTC89cZ-zH5aTp4JayMIQQUuLmbHh1VHq1GJe0I3sM1iBIvIApUPT3rfLtqCYhG1qJzDPmyu80WsVPwPZh8YAmMOzbFYSL-neaICu3JjkEkc4iQpDI_DYvbkzkzL1IY9D2JGH/s320/ntservice_setting.JPG" width="320" /></a></div>
<br /></div>
sinocgtchenhttp://www.blogger.com/profile/16792615667276760427noreply@blogger.com7