{"id":152,"date":"2019-09-01T13:05:14","date_gmt":"2019-09-01T05:05:14","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=152"},"modified":"2020-09-26T22:44:05","modified_gmt":"2020-09-26T14:44:05","slug":"arduino%e7%ba%a2%e5%a4%96%e9%81%a5%e6%8e%a7%e8%88%b5%e6%9c%ba","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=152","title":{"rendered":"Arduino\u7ea2\u5916\u9065\u63a7\u8235\u673a"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include \"IRremote.h\"\n#include &lt;Servo.h>\nint RECV_PIN = 11;\nint SERVO_PIN = 9;\nServo myservo;\nIRrecv irrecv(RECV_PIN);\ndecode_results results;\nvoid setup() {\n  pinMode(RECV_PIN, INPUT);\n  Serial.begin(9600);\n  irrecv.enableIRIn();\n  myservo.attach(SERVO_PIN);\n}\nvoid loop() {\n  if (irrecv.decode(&amp;results)) \n  {\n    Serial.println(results.value);\n    int angle = results.value % 180;\n    myservo.write(angle);\n    delay(100);\n    irrecv.resume();\n  }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"240\" height=\"448\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/09\/225617n6irixqf88vm8luq.jpg\" alt=\"\" class=\"wp-image-153\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/09\/225617n6irixqf88vm8luq.jpg 240w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/09\/225617n6irixqf88vm8luq-161x300.jpg 161w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><\/figure>\n\n\n\n<p>VOUT\u63a511\u53f7\u53e3<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/09\/IRremote.zip\">IRremote<\/a><a href=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/09\/IRremote.zip\" class=\"wp-block-file__button\" download>\u4e0b\u8f7d<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>VOUT\u63a511\u53f7\u53e3<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/152"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":2,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}