{"id":79,"date":"2014-08-15T16:01:50","date_gmt":"2014-08-15T08:01:50","guid":{"rendered":"http:\/\/192.168.100.100\/wordpress\/2014\/08\/15\/arduino-%e5%bb%b6%e4%bc%b8%e5%ad%b8%e7%bf%92%e5%af%a6%e4%bd%9c%e4%b8%80-%e5%85%89%e6%8e%a7%e8%aa%bf%e7%af%80\/"},"modified":"2023-01-28T15:05:33","modified_gmt":"2023-01-28T07:05:33","slug":"arduino-%e5%bb%b6%e4%bc%b8%e5%ad%b8%e7%bf%92%e5%af%a6%e4%bd%9c%e4%b8%80-%e5%85%89%e6%8e%a7%e8%aa%bf%e7%af%80","status":"publish","type":"post","link":"https:\/\/blog.godzeng.com\/?p=79","title":{"rendered":"Arduino \u5ef6\u4f38\u5b78\u7fd2\u5be6\u4f5c(\u4e00)  \u5149\u63a7\u8abf\u7bc0"},"content":{"rendered":"<p><span style=\"font-size: 12pt;\">\u6211\u76f8\u4fe1 <a href=\"http:\/\/o4043380.pixnet.net\/blog\/post\/172903534\">\u65b0\u624b\u5be6\u4f5c \u5149\u63a7\u958b\u95dc<\/a> \u5927\u5bb6\u90fd\u61c9\u8a72\u4e86\u89e3\u5230 \u5149\u654f\u96fb\u963b\u7684\u539f\u7406\u61c9\u7528 &nbsp;\u9019\u6b21\u6211\u963f\u4fca \u5e36\u4f86 \u5149\u63a7\u8abf\u7bc0 \u4e5f\u5c31\u662f\u6240\u8b02\u7684\u74b0\u5883\u5149\u4eae\u5ea6\u8abf\u6574\u7684\u5be6\u4f5c \u73fe\u5728\u7684\u667a\u6167\u578b\u624b\u6a5f \u90fd\u4e00\u5b9a\u6709\u7684\u529f\u80fd \u4f9d\u7167\u5149\u654f\u96fb\u963b \u6240\u6e2c\u51fa\u4f86\u7684\u503c &nbsp;\u6539\u8b8a\u8981\u8b93LED\u4eae\u5e7e\u500b\u71c8 &nbsp;\u4ee5\u4e0b\u662f\u5be6\u4f5c\u7684\u5f71\u7247<\/span><\/p>\n<p>\n<script src=\"http:\/\/ext.pixnet.tv\/user\/o4043380\/embed\/movie\/539036281.js\" type=\"text\/javascript\"><\/script><br \/>\n&nbsp;&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u6750\u6599\u6e96\u5099<\/span><\/p>\n<p><a href=\"http:\/\/o4043380.pixnet.net\/album\/photo\/539036974\"><img title=\"\u5149\u63a7\u8abf\u7bc0\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1408089126-1013847291_m.jpg\" alt=\"\u5149\u63a7\u8abf\u7bc0\" border=\"0\" \/><\/a> &nbsp;<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">Arduino \u677f\u5b50&nbsp;<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">\u6578\u689d\u9023\u63a5\u7dda<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">1K\u6b50\u59c6 X6<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">10K\u6b50\u59c6 X1<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">\u5149\u654f\u96fb\u963b X1<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">LED X 6<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"font-size: 12pt;\">\u9eb5\u5305\u677f<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"color: #000000; font-size: 12pt;\">\u5b98\u65b9\u7a0b\u5f0f\u7de8\u8b6f\u5668&nbsp;arduino-1.X.X\u4ee5\u4e0a\u7248\u672c<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\">&nbsp;<\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"color: #000000; font-size: 12pt;\">\u63a5\u4e0b\u4f86\u662f\u96fb\u8def\u5716<\/span><\/p>\n<p style=\"margin: 0px 0px 1em; padding: 0px; color: #666666; font-family: Helvetica, Arial, 'LiHei Pro', PMingLiU, sans-serif; font-size: 13px; line-height: 26px;\"><span style=\"color: #000000; font-size: 12pt;\"><img title=\"\u5149\u63a7\u8abf\u7bc01\" src=\"http:\/\/pic.pimg.tw\/o4043380\/1408090379-2209207533_n.png\" alt=\"\u5149\u63a7\u8abf\u7bc01\" border=\"0\" \/> &nbsp;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u9019\u6b21\u96fb\u8def\u5716 \u7dda\u8def\u591a\u4e86\u4e00\u4e9b \u57fa\u672c\u4e0a \u5728\u5149\u63a7\u958b\u95dc \u6709\u505a\u904e\u7684 \u57fa\u672c\u4e0a \u90fd\u662f\u4e00\u6a23\u7684\u6771\u897f \u53ea\u662f\u591a\u4e865\u500bLED\u548c\u96fb\u963b\u800c\u5df2!~<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u518d\u4f86\u662f\u7a0b\u5f0f\u78bc<\/span><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>\/\/ Arduino \u3000\u65b0\u624b\u5be6\u4f5c\u3000\u5149\u7a7a\u8abf\u7bc0 by~\u3000\u963f\u4fca<\/p>\n<p>int photocellPin = 1; \/\/ \u5149\u654f\u96fb\u963b\u63a5\u5230\u6a21\u64ec\u5f15\u8173A1<br \/>int photocellVal = 0; \/\/ \u3000\u8a2d\u5b9a\u5149\u611f\u521d\u59cb\u503c\u70ba0<br \/>int LED1 = 8; \/\/\u3000\u5b9a\u7fa9LED\u8173\u4f4d\u70ba8<br \/>int LED2 = 7; \/\/\u3000\u5b9a\u7fa9LED\u8173\u4f4d\u70ba7<br \/>int LED3 = 6; \/\/\u3000\u5b9a\u7fa9LED\u8173\u4f4d\u70ba6<br \/>int LED4 = 5; \/\/\u3000\u5b9a\u7fa9LED\u8173\u4f4d\u70ba5<br \/>int LED5 = 4; \/\/\u3000\u5b9a\u7fa9LED\u8173\u4f4d\u70ba4<br \/>int LED6 = 3; \/\/\u3000\u5b9a\u7fa9LED\u8173\u4f4d\u70ba3<\/p>\n<p>void setup() {<br \/> pinMode(LED1, OUTPUT);\/\/\u3000\u5b9a\u7fa9LED\u70ba\u8f38\u51fa\u8173<br \/> pinMode(LED2, OUTPUT);\/\/\u3000\u5b9a\u7fa9LED\u70ba\u8f38\u51fa\u8173<br \/> pinMode(LED3, OUTPUT);\/\/\u3000\u5b9a\u7fa9LED\u70ba\u8f38\u51fa\u8173<br \/> pinMode(LED4, OUTPUT);\/\/\u3000\u5b9a\u7fa9LED\u70ba\u8f38\u51fa\u8173<br \/> pinMode(LED5, OUTPUT);\/\/\u3000\u5b9a\u7fa9LED\u70ba\u8f38\u51fa\u8173<br \/> pinMode(LED6, OUTPUT);\/\/\u3000\u5b9a\u7fa9LED\u70ba\u8f38\u51fa\u8173<br \/> Serial.begin(9600);\/\/\u3000\u8a2d\u5b9a\u76e3\u63a7\u8996\u7a97\u50b3\u8f38\u901f\u5ea6<br \/>}<\/p>\n<p>void loop() {<br \/> photocellVal = analogRead(photocellPin); \/\/\u5149\u611f\u503c\u4f86\u6e90\u70ba\u5149\u654f\u96fb\u963b\u6240\u6e2c\u7684\u503c<br \/> Serial.println(photocellVal); \/\/\u3000\u5c07\u6240\u6e2c\u51fa\u4f86\u7684\u503c\u986f\u793a\u5728\u76e3\u63a7\u8996\u7a97<br \/> delay(100); \/\/\u3000\u5ef6\u90720.1\u79d2<\/p>\n<p>if (photocellVal&gt;600)<br \/>{<br \/>digitalWrite(LED1,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED2,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED3,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED4,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED5,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED6,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>}<br \/>if (photocellVal&lt;600)<br \/>{<br \/>digitalWrite(LED1,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED2,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED3,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED4,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED5,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED6,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>}<br \/>if (photocellVal&lt;500)<br \/>{<br \/>digitalWrite(LED1,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED2,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED3,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED4,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED5,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED6,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>}<br \/>if (photocellVal&lt;400)<br \/>{<br \/>digitalWrite(LED1,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED2,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED3,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED4,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED5,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>digitalWrite(LED6,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>}<br \/>if (photocellVal&lt;300)<br \/>{<br \/>digitalWrite(LED1,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED2,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED3,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED4,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED5,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED6,0); \/\/\u3000\u95dc\u9589LED\u767b<br \/>}<br \/>if (photocellVal&lt;200)<br \/>{<br \/>digitalWrite(LED1,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED2,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED3,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED4,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED5,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>digitalWrite(LED6,1); \/\/\u3000\u958b\u555fLED\u767b<br \/>}<br \/>}<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u9019\u6b21\u7684\u7a0b\u5f0f \u662f\u8b93\u689d\u4ef6 \u6709\u591a\u9805\u5f0f\u9078\u64c7 \u5149\u611f\u503c\u5927\u65bc600 \u4e5f\u5c31\u662f\u74b0\u5883\u5149\u5f88\u4eae \u9019\u88e1\u6578\u503c\u53ef\u4ee5\u7528\u76e3\u63a7\u8996\u7a97 \u4f86\u7372\u53d6 \u6293\u5230\u81ea\u5df1\u60f3\u8981\u7684\u503c \u5c31\u53ef\u4ee5\u5728\u7a0b\u5f0f\u88e1 \u9032\u884c\u4fee\u6539 \u6211\u7684\u65b9\u6cd5\u662f \u5927\u65bc600 \u4eae1 5\u6d88 \u5c0f\u65bc600 \u4eae2 4\u6d88 &nbsp;\u5c0f\u65bc500 \u4eae3 3\u6d88 \u4ee5\u6b64\u5217\u63a8\u4e0b\u53bb<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 12pt;\">\u7d50\u8ad6 &nbsp;\u9019\u6b21\u5be6\u4f5c \u4e86\u89e3\u5230[ IF ] \u5f97\u597d\u7528\u4e4b\u8655 &nbsp;\u5728\u689d\u4ef6\u5224\u65b7\u5f0f\u4e2d IF \u5c31\u975e\u5e38\u91cd\u8981 &nbsp;\u4ed6\u80fd\u7ba1\u7406 \u5468\u908a\u914d\u4ef6\u7684\u904b\u4f5c \u689d\u4ef6\u8a2d\u5b9a\u597d \u4ed6\u5c31\u6703\u5206\u8fa8\u7406\u89e3\u5224\u5b9a\u57f7\u884c \u4f60\u770b Arduino \u591a\u9ebc\u795e\u5947\u662f\u5427~~~ \u8b1d\u8b1d\u5927\u5bb6 by \u963f\u4fca~<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u76f8\u4fe1 \u65b0\u624b\u5be6\u4f5c \u5149\u63a7\u958b\u95dc \u5927\u5bb6\u90fd\u61c9\u8a72\u4e86\u89e3\u5230 \u5149\u654f\u96fb\u963b\u7684\u539f\u7406\u61c9\u7528 &nbsp;\u9019\u6b21\u6211\u963f\u4fca \u5e36\u4f86 \u5149\u63a7\u8abf\u7bc0 \u4e5f\u5c31 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts\/79"}],"collection":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79"}],"version-history":[{"count":1,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":551,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions\/551"}],"wp:attachment":[{"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.godzeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}