{"id":2803,"date":"2018-05-31T15:30:39","date_gmt":"2018-05-31T07:30:39","guid":{"rendered":"https:\/\/drho.club\/?p=2215"},"modified":"2018-05-31T15:30:39","modified_gmt":"2018-05-31T07:30:39","slug":"arduino-ir-controller-counter","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2018\/05\/31\/arduino-ir-controller-counter\/","title":{"rendered":"\u3010Arduino\u3011\u7d05\u5916\u7dda\u611f\u6e2c\u5668\u5be6\u7fd2"},"content":{"rendered":"<p>\u7d05\u5916\u7dda\u662f\u76ee\u524d\u8a31\u591a\u96fb\u5668\u5e38\u7528\u7684\u9059\u63a7\u5668\u6a19\u6e96\u901a\u8a0a\u65b9\u5f0f\uff0c\u56e0\u6b64\u662f\u975e\u5e38\u9069\u7528\u65bc\u5d4c\u5165\u5f0f\u7cfb\u7d71\u4e2d\u4f7f\u7528\u7684\u901a\u8a0a\u65b9\u6cd5\uff0c\u4e8b\u5be6\u4e0a\u4e5f\u5e7e\u4e4e\u662f\u6a19\u6e96\u7684\u901a\u8a0a\u6a21\u7d44\uff0c\u6709\u975e\u5e38\u591a\u73fe\u6210\u7684\u7a0b\u5f0f\u4ee5\u53ca\u96fb\u8def\u53ef\u4ee5\u5229\u7528\uff0c\u800c\u4e14\u5176\u96f6\u4ef6\u4e5f\u975e\u7576\u4fbf\u5b9c\u3002\u4e0b\u5716\u662f\u6211\u5011\u9019\u6b21\u8981\u5be6\u7fd2\u7bc4\u4f8b\u7684\u4e3b\u89d2\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31-14.51.06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2219\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31-14.51.06.jpg\" alt=\"\" width=\"159\" height=\"300\" \/><\/a><\/p>\n<p>\u9019\u500b\u7d05\u5916\u7dda\u63a5\u6536\u5668\u6709\u4e09\u652f\u8173\uff0c\u5176\u4e2d\u6700\u53f3\u908a\u9019\u652f\u662f5V\uff0c\u4e2d\u9593\u662fGND\uff0c\u5de6\u908a\u7684\u90a3\u652f\u63a5\u8173\u5247\u662f\u8f38\u51fa\u7684\u8173\u4f4d\u3002\u9023\u63a5\u4e4b\u5f8c\u7684\u6a23\u5b50\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31-14.51.23.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2220\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31-14.51.23.jpg\" alt=\"\" width=\"700\" height=\"525\" \/><\/a><\/p>\n<p>\u5982\u4e0a\u5716\u6240\u793a\uff0c\u5176\u5be6\u5c31\u662f\u7d66\u5b83\u4e00\u500b\u96fb\u6e90\uff0c\u7136\u5f8c\u628a\u4fe1\u865f\u7dda\u9023\u63a5\u5230\u6578\u4f4d\u63a5\u8173\u4e2d\u7684\u5176\u4e2d\u4e00\u500b\u5c31\u53ef\u4ee5\u4e86\u3002\u5728\u5716\u7247\u4e2d\u6211\u5011\u662f\u628a\u5b83\u9023\u63a5\u5230\u7b2c2\u8173\uff0c\u4f46\u662f\u5728\u4e0b\u9762\u7684\u7bc4\u4f8b\u4e2d\u6709\u4e9b\u5247\u662f\u9023\u7dda\u5230\u7b2c11\u652f\u8173\uff0c\u540c\u5b78\u5011\u5728\u57f7\u884c\u7a0b\u5f0f\u7684\u6642\u5019\u8981\u7279\u5225\u5730\u7559\u610f\u3002\u9023\u63a5\u5b8c\u6210\u4e4b\u5f8c\uff0c\u63a5\u4e0b\u4f86\u662f\u904b\u7528\u7a0b\u5f0f\u5eab\u4f86\u7de8\u5beb\u7a0b\u5f0f\u3002\u5728\u9019\u88e1\u6211\u5011\u4e0d\u6253\u7b97\u4f7f\u7528\u9810\u8a2d\u7684\u9a45\u52d5\u7a0b\u5f0f\uff0c\u6240\u4ee5\u8acb\u5148\u5230\u7a0b\u5f0f\u96c6\u7684\u76ee\u9304\u4e0b\uff0c\u628aRobotIRemote\u9019\u500b\u8cc7\u6599\u593e\u79fb\u9664\uff08\u5efa\u8b70\u5148\u79fb\u52d5\u5230\u5225\u7684\u5730\u65b9\uff09\uff0c\u4f4d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-04-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2216 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-04-10.png\" alt=\"\" width=\"607\" height=\"418\" \/><\/a><\/p>\n<p>\u7136\u5f8c\u8acb\u5230\u3010<a href=\"https:\/\/github.com\/z3t0\/Arduino-IRremote\">\u9019\u88e1<\/a>\u3011\u4e0b\u8f09\u53e6\u5916\u4e00\u652f\u9a45\u52d5\u7a0b\u5f0f\uff0c\u4e0b\u8f09ZIP\u58d3\u7e2e\u6a94\u4e4b\u5f8c\uff0c\u5982\u4e4b\u524d\u6240\u6709\u7684\u7bc4\u4f8b\u4e00\u6a23\uff0c\u5148\u505a\u89e3\u58d3\u7e2e\u7684\u52d5\u4f5c\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-05-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2217 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-05-02.png\" alt=\"\" width=\"533\" height=\"127\" \/><\/a><\/p>\n<p>\u63a5\u8457\uff0c\u95dc\u9589Arduino IDE\u4e4b\u5f8c\u518d\u91cd\u65b0\u958b\u555f\u4e00\u6b21\uff0c\u5c31\u53ef\u4ee5\u5728Arduino IDE\u4e2d\u770b\u5230\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-20-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2221\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-20-08.png\" alt=\"\" width=\"645\" height=\"883\" \/><\/a><\/p>\n<p>\u958b\u555f\u4e4b\u7bc4\u4f8b\u7a0b\u5f0f\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>[code]<br \/>\n\/*<br \/>\n * IRremote: IRrecvDemo &#8211; demonstrates receiving IR codes with IRrecv<br \/>\n * An IR detector\/demodulator must be connected to the input RECV_PIN.<br \/>\n * Version 0.1 July, 2009<br \/>\n * Copyright 2009 Ken Shirriff<br \/>\n * http:\/\/arcfn.com<br \/>\n *\/<\/p>\n<p>#include &lt;IRremote.h&gt;<\/p>\n<p>int RECV_PIN = 11;<\/p>\n<p>IRrecv irrecv(RECV_PIN);<\/p>\n<p>decode_results results;<\/p>\n<p>void setup()<br \/>\n{<br \/>\n  Serial.begin(9600);<br \/>\n  \/\/ In case the interrupt driver crashes on setup, give a clue<br \/>\n  \/\/ to the user what&#8217;s going on.<br \/>\n  Serial.println(&quot;Enabling IRin&quot;);<br \/>\n  irrecv.enableIRIn(); \/\/ Start the receiver<br \/>\n  Serial.println(&quot;Enabled IRin&quot;);<br \/>\n}<\/p>\n<p>void loop() {<br \/>\n  if (irrecv.decode(&amp;results)) {<br \/>\n    Serial.println(results.value, HEX);<br \/>\n    irrecv.resume(); \/\/ Receive the next value<br \/>\n  }<br \/>\n  delay(100);<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>\u8acb\u7559\u610f\uff0c\u9019\u500b\u7bc4\u4f8b\u7a0b\u5f0f\u6211\u5011\u662f\u4f7f\u7528\u7b2c11\u652f\u8173\u505a\u70ba\u53d6\u5f97\u7d05\u5916\u7dda\u8a0a\u865f\u7684\u8f38\u51fa\u7aef\u3002\u628a\u6b64\u7a0b\u5f0f\u4e0a\u50b3\u71d2\u9304\u5230Arduino\u4e4b\u5f8c\uff0c\u8acb\u958b\u555f\u76e3\u63a7\u8996\u7a97\uff0c\u7136\u5f8c\u96a8\u4fbf\u627e\u4e00\u500b\u9059\u63a7\u5668\uff08\u7b46\u8005\u4f7f\u7528\u7684\u662f\u5438\u9802\u5f0f\u96fb\u6247\u7528\u7684\uff09\u5982\u4e0b\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31-15.25.18.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2222\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31-15.25.18.jpg\" alt=\"\" width=\"600\" height=\"450\" \/><\/a><\/p>\n<p>\u5c0d\u8457\u90a3\u500b\u63a5\u6536\u5668\u6309\u4e0d\u540c\u7684\u6309\u9215\uff0c\u5c31\u6703\u5728\u76e3\u63a7\u8996\u7a97\u4e2d\u770b\u5230\u5982\u4e0b\u6240\u793a\u7684\u5b57\u4e32\u4e86\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-24-07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2223\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/05\/2018-05-31_15-24-07.png\" alt=\"\" width=\"689\" height=\"500\" \/><\/a><\/p>\n<p>\u9059\u63a7\u5668\u7684\u6bcf\u4e00\u500b\u6309\u9215\u90fd\u5c0d\u61c9\u4e86\u4e0d\u540c\u5b57\u4e32\uff0c\u4e5f\u5c31\u662f\u8aaa\uff0c\u900f\u904e\u6b64\u7d05\u5916\u7dda\u7684\u5b57\u4e32\u8b58\u5225\uff0c\u5c31\u53ef\u4ee5\u505a\u5230\u9059\u63a7\u7684\u529f\u80fd\u56c9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d05\u5916\u7dda\u662f\u76ee\u524d\u8a31\u591a\u96fb\u5668\u5e38\u7528\u7684\u9059\u63a7\u5668\u6a19\u6e96\u901a\u8a0a\u65b9\u5f0f\uff0c\u56e0\u6b64\u662f\u975e\u5e38\u9069\u7528\u65bc\u5d4c\u5165\u5f0f\u7cfb\u7d71\u4e2d\u4f7f\u7528\u7684\u901a\u8a0a\u65b9\u6cd5\uff0c\u4e8b\u5be6\u4e0a\u4e5f\u5e7e\u4e4e\u662f\u6a19\u6e96\u7684\u901a\u8a0a\u6a21\u7d44\uff0c\u6709\u975e\u5e38\u591a\u73fe\u6210\u7684\u7a0b\u5f0f\u4ee5\u53ca\u96fb\u8def\u53ef\u4ee5\u5229\u7528\uff0c\u800c\u4e14\u5176\u96f6\u4ef6\u4e5f\u975e\u7576\u4fbf\u5b9c\u3002\u5728\u9019\u500b\u5be6\u7fd2\u4e2d\uff0c\u6211\u5011\u5c31\u4f86\u77ad\u89e3\u5982\u4f55\u628a\u7d05\u5916\u7dda\u9059\u63a7\u5668\u904b\u7528\u5230\u6211\u5011\u7684Arduino\u5c08\u984c\u4e2d\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2803","post","type-post","status-publish","format-standard","hentry","category-arduino"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=2803"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2803\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}