{"id":313,"date":"2017-02-04T16:25:26","date_gmt":"2017-02-04T08:25:26","guid":{"rendered":"http:\/\/192.168.1.20\/?p=313"},"modified":"2017-02-04T16:25:26","modified_gmt":"2017-02-04T08:25:26","slug":"{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}e4{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}bd{47dd41ec6bdcbd9a214c783a3735392b82ea6d1d918378c5a53e0640702d813","status":"publish","type":"post","link":"http:\/\/alextop.top\/?p=313","title":{"rendered":"\u4f7f\u7528 RPi.GPIO \u6a21\u5757\u7684\u8f93\u51fa\uff08Output\uff09\u529f\u80fd"},"content":{"rendered":"<p>\n\u00a0<\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:Times\">1<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3001\u9996\u5148\u5bf9<\/span><span style=\"font-family:Times\"> RPi.GPIO <\/span><span style=\"font-family:\u5b8b\u4f53\">\u8fdb\u884c\u8bbe\u7f6e\uff08\u6839\u636e<a href=\"http:\/\/shumeipai.nxez.com\/2016\/09\/28\/rpi-gpio-module-basics.html\" title=\"RPi.GPIO \u6a21\u5757\u4f7f\u7528\u57fa\u7840\" target=\"_blank\"><span style=\"color:#3390ca\">\u8fd9\u91cc<\/span><\/a>\u7684\u63cf\u8ff0\uff09<\/span><span style=\"font-family:Times\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">import RPi.GPIO as GPIO<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.setmode(GPIO.BOARD)<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.setup(12, GPIO.OUT)<br \/>\n<\/span><\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:Times\">2<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3001\u8bbe\u7f6e\u67d0\u4e2a\u8f93\u51fa\u9488\u811a\u72b6\u6001\u4e3a\u9ad8\u7535\u5e73\uff1a<\/span><span style=\"font-family:Times\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, GPIO.HIGH)<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-size:10pt\"><span style=\"font-family:Consolas\"> # <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6216\u8005<\/span><span style=\"font-family:Consolas\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, 1)<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-size:10pt\"><span style=\"font-family:Consolas\"> # <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6216\u8005<\/span><span style=\"font-family:Consolas\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, True)<br \/>\n<\/span><\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:Times\">3<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3001\u8bbe\u7f6e\u67d0\u4e2a\u8f93\u51fa\u9488\u811a\u72b6\u6001\u4e3a\u4f4e\u7535\u5e73\uff1a<\/span><span style=\"font-family:Times\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, GPIO.LOW)<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-size:10pt\"><span style=\"font-family:Consolas\"> # <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6216\u8005<\/span><span style=\"font-family:Consolas\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, 0)<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-size:10pt\"><span style=\"font-family:Consolas\"> # <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6216\u8005<\/span><span style=\"font-family:Consolas\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, False)<br \/>\n<\/span><\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:Times\">4<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3001\u7a0b\u5e8f\u7ed3\u675f\u540e\u8fdb\u884c\u6e05\u7406<\/span><span style=\"font-family:Times\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.cleanup()<br \/>\n<\/span><\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:\u5b8b\u4f53\">\u6ce8\u610f\uff0c\u60a8\u53ef\u4ee5\u8bfb\u53d6\u4f7f\u7528<\/span><span style=\"font-family:Times\"> input() <\/span><span style=\"font-family:\u5b8b\u4f53\">\u51fd\u6570\u8bbe\u7f6e\u7684\u8f93\u51fa\u901a\u9053\u7684\u5f53\u524d\u72b6\u6001\u3002\u4f8b\u5982\u5bf9\u8f93\u51fa\u8fdb\u884c\u5207\u6362\uff1a<\/span><span style=\"font-family:Times\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7\"><span style=\"color:#333333; font-family:Consolas; font-size:10pt\">GPIO.output(12, not GPIO.input(12))<br \/>\n<\/span><\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:\u5b8b\u4f53\"><strong>\u76f8\u5173\u7f51\u7ad9<\/strong><\/span><span style=\"font-family:Times\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u539f\u6587\u5730\u5740\uff1a<a href=\"https:\/\/code.google.com\/p\/raspberry-gpio-python\/wiki\/Outputs\" title=\"RPi.GPIO module Outputs\" target=\"_blank\"\/><\/span><span style=\"color:#3390ca\"><span style=\"font-family:Times\">RPi.GPIO module Outputs<span style=\"color:#333a42\"><br \/><\/span><\/span><span style=\"font-family:\u5b8b\u4f53\">\u9879\u76ee\u5730\u5740\uff1a<a href=\"https:\/\/code.google.com\/p\/raspberry-gpio-python\/\" title=\"RPi.GPIO\" target=\"_blank\"\/><\/span><span style=\"font-family:Times\">RPi.GPIO<span style=\"color:#333a42\"><br \/><\/span><\/span><span style=\"font-family:\u5b8b\u4f53\">\u539f\u6587\u7ffb\u8bd1\uff1a<a href=\"http:\/\/dreamcolor.net\/archives\/rpi-gpio-module-outputs.html\" target=\"_blank\"\/><\/span><span style=\"font-family:Times\">dreamcolor.net<span style=\"color:#333a42\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"color:#333a42; font-size:11pt\"><span style=\"font-family:\u5b8b\u4f53\">\u672c\u6587\u6765\u81ea\uff1a<a href=\"http:\/\/shumeipai.nxez.com\/\" title=\"\u6811\u8393\u6d3e\u5b9e\u9a8c\u5ba4\"><span style=\"color:#3390ca\">\u6811\u8393\u6d3e\u5b9e\u9a8c\u5ba4<\/span><\/a><\/span><span style=\"font-family:Times\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u94fe\u63a5\u5730\u5740\uff1a<a href=\"http:\/\/shumeipai.nxez.com\/2016\/09\/28\/rpi-gpio-module-outputs.html\" title=\"\u4f7f\u7528 RPi.GPIO \u6a21\u5757\u7684\u8f93\u51fa\uff08Output\uff09\u529f\u80fd\"\/><\/span><span style=\"color:#3390ca; font-family:Times\">http:\/\/shumeipai.nxez.com\/2016\/09\/28\/rpi-gpio-module-outputs.html<span style=\"color:#333a42\"><br \/>\n\t\t\t\t<\/span><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 1\u3001\u9996\u5148\u5bf9 RPi.GPI&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-reapberry"],"_links":{"self":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/313"}],"collection":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":0,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions"}],"wp:attachment":[{"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}