{"id":294,"date":"2017-02-04T15:41:25","date_gmt":"2017-02-04T07:41:25","guid":{"rendered":"http:\/\/192.168.1.20\/?p=294"},"modified":"2017-02-04T16:06:47","modified_gmt":"2017-02-04T08:06:47","slug":"rpi-gpio-{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}e6{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}a8{47dd41ec6bdcbd9a214c783a3735392b82ea6d1d918378c5a53e06","status":"publish","type":"post","link":"http:\/\/alextop.top\/?p=294","title":{"rendered":"RPi.GPIO \u6a21\u5757\u4f7f\u7528\u57fa\u7840"},"content":{"rendered":"<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: Times;\">RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6a21\u5757\u7a0b\u5e8f\u5305\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5728<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e2d\u63a7\u5236<\/span><span style=\"font-family: Times;\"> GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7684\u7c7b\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u6ce8\u610f\uff0c\u8be5\u6a21\u5757\u4e0d\u9002\u5408\u5e94\u7528\u5230\u8ffd\u6c42\u5b9e\u65f6\u6027\u6216\u8ba1\u6570\u5468\u671f\u7684\u5e94\u7528\u4e2d\u3002\u8fd9\u662f\u7531\u4e8e\u60a8\u65e0\u6cd5\u9884\u6d4b<\/span><span style=\"font-family: Times;\"> Ptyhon <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4f55\u65f6\u7e41\u5fd9\uff0c\u4ee5\u53ca\u8d44\u6e90\u56de\u6536\u7684\u65f6\u95f4\u3002\u800c\u4e14\u5b83\u662f\u8fd0\u884c\u5728\u57fa\u4e8e<\/span><span style=\"font-family: Times;\"> Linux <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6838\u5fc3\u7684\u7cfb\u7edf\u4e2d\uff0c\u4e5f\u4e0d\u5408\u9002\u7528\u4e8e\u5b9e\u65f6\u5e94\u7528<\/span><span style=\"font-family: Times;\"> \u2013 <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u539f\u56e0\u5728\u4e8e\u5176\u5b83\u8fdb\u7a0b\u53ef\u80fd\u83b7\u5f97\u66f4\u9ad8\u7684<\/span><span style=\"font-family: Times;\"> CPU <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4f18\u5148\u7ea7\u3002\u5982\u679c\u60a8\u4e00\u5b9a\u8981\u8ffd\u6c42\u5b9e\u65f6\u64cd\u4f5c\u7684\u6027\u80fd\uff0c\u53ef\u4ee5\u8003\u8651\u8d2d\u4e70\u4e00\u5757<\/span><span style=\"font-family: Times;\"> Arduino <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e3b\u677f<\/span><span style=\"color: #3390ca; font-family: Times;\">http:\/\/www.arduino.cc<span style=\"color: #333a42;\">!<br \/>\n<\/span><\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u8fd8\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u76ee\u524d\u7684\u7248\u672c\u8fd8\u4e0d\u652f\u6301<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7684<\/span><span style=\"font-family: Times;\"> SPI<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u3001<\/span><span style=\"font-family: Times;\">I2C<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u3001<\/span><span style=\"font-family: Times;\">1-wire<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u3001\u4e32\u53e3\u7b49\u529f\u80fd\u3002\u8ba1\u5212\u5728\u4e0d\u4e45\u7684\u5c06\u6765\u4f1a\u5b9e\u73b0\u7684\uff01<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u672c\u6587\u662f<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6a21\u5757\u6587\u6863\u7cfb\u5217\u6587\u7ae0\u7684\u7b2c\u4e00\u7bc7\uff0c\u9664\u672c\u6587\u5916\u8fd8\u5305\u62ec\u4ee5\u4e0b\u51e0\u7bc7\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #3390ca; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6a21\u5757\u7684\u8f93\u5165\uff08<\/span><span style=\"font-family: Times;\">Input<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u529f\u80fd<\/span><span style=\"color: #333a42;\"><span style=\"font-family: Times;\"><br \/>\n<\/span><span style=\"color: #3390ca;\"><span style=\"font-family: \u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6a21\u5757\u7684\u8f93\u51fa\uff08<\/span><span style=\"font-family: Times;\">Output<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u529f\u80fd<\/span><span style=\"color: #333a42;\"><span style=\"font-family: Times;\"><br \/>\n<\/span><span style=\"color: #3390ca;\"><span style=\"font-family: \u5b8b\u4f53;\">\u4f7f\u7528<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6a21\u5757\u7684\u8109\u5bbd\u8c03\u5236\uff08<\/span><span style=\"font-family: Times;\">PWM<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u529f\u80fd<\/span><span style=\"color: #333a42; font-family: Times;\"><br \/>\n<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u5bfc\u5165\u6a21\u5757<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u5bfc\u5165<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6a21\u5757\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/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><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u901a\u8fc7\u8be5\u64cd\u4f5c\uff0c\u60a8\u53ef\u4ee5\u5c06\u6a21\u5757\u540d\u79f0\u6620\u5c04\u4e3a<\/span><span style=\"font-family: Times;\"> GPIO<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff0c\u4ee5\u4fbf\u63a5\u4e0b\u6765\u60a8\u5176\u5b83\u811a\u672c\u8fdb\u884c\u4f7f\u7528\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u5bfc\u5165\u6a21\u5757\u5e76\u68c0\u67e5\u5b83\u662f\u5426\u5bfc\u5165\u6210\u529f\uff0c\u53ef\u4ee5\u5c1d\u8bd5\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">try:<br \/>\n<\/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;\">except RuntimeError:<br \/>\n<\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-size: 10pt;\"><span style=\"font-family: Consolas;\"> print(&#8220;<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u5bfc\u5165<\/span><span style=\"font-family: Consolas;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u65f6\u51fa\u73b0\u9519\u8bef\uff01\u8fd9\u53ef\u80fd\u7531\u4e8e\u6ca1\u6709\u8d85\u7ea7\u7528\u6237\u6743\u9650\u9020\u6210\u7684\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528<\/span><span style=\"font-family: Consolas;\"> &#8216;sudo&#8217; <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6765\u8fd0\u884c\u60a8\u7684\u811a\u672c\u3002<\/span><span style=\"font-family: Consolas;\">&#8220;)<br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u9488\u811a\u7f16\u53f7<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u76ee\u524d\u6709\u4e24\u79cd\u65b9\u5f0f\u53ef\u4ee5\u901a\u8fc7<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u5bf9<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e0a\u7684<\/span><span style=\"font-family: Times;\"> IO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u9488\u811a\u8fdb\u884c\u7f16\u53f7\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u7b2c\u4e00\u79cd\u65b9\u5f0f\u662f\u4f7f\u7528<\/span><span style=\"font-family: Times;\"> BOARD <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7f16\u53f7\u7cfb\u7edf\u3002\u8be5\u65b9\u5f0f\u53c2\u8003<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e3b\u677f\u4e0a<\/span><span style=\"font-family: Times;\"> P1 <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u63a5\u7ebf\u67f1\u7684\u9488\u811a\u7f16\u53f7\u3002\u4f7f\u7528\u8be5\u65b9\u5f0f\u7684\u4f18\u70b9\u662f\u65e0\u9700\u8003\u8651\u4e3b\u677f\u7684\u4fee\u8ba2\u7248\u672c\uff0c\u60a8\u786c\u4ef6\u59cb\u7ec8\u90fd\u662f\u53ef\u7528\u7684\u72b6\u6001\u3002\u60a8\u5c06\u65e0\u9700\u4ece\u65b0\u8fde\u63a5\u7ebf\u8def\u548c\u66f4\u6539\u60a8\u7684\u4ee3\u7801\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u662f\u4f7f\u7528<\/span><span style=\"font-family: Times;\"> BCM <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7f16\u53f7\u3002\u8fd9\u662f\u4e00\u79cd\u8f83\u4f4e\u5c42\u7684\u5de5\u4f5c\u65b9\u5f0f<\/span><span style=\"font-family: Times;\"> \u2013 <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u8be5\u65b9\u5f0f\u53c2\u8003<\/span><span style=\"font-family: Times;\"> Broadcom SOC <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7684\u901a\u9053\u7f16\u53f7\u3002\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u60a8\u59cb\u7ec8\u8981\u4fdd\u8bc1\u4e3b\u677f\u4e0a\u7684\u9488\u811a\u4e0e\u56fe\u8868\u4e0a\u6807\u6ce8\u7684\u901a\u9053\u7f16\u53f7\u76f8\u5bf9\u5e94\u3002\u60a8\u7684\u811a\u672c\u53ef\u80fd\u5728<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e3b\u677f\u8fdb\u884c\u4fee\u8ba2\u7248\u672c\u66f4\u65b0\u65f6\u65e0\u6cd5\u5de5\u4f5c\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u6307\u5b9a\u60a8\u6240\u4f7f\u7528\u7684\u65b9\u5f0f\uff08\u5fc5\u987b\u6307\u5b9a\uff09\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/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><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u6216\u8005<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.setmode(GPIO.BCM)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u8b66\u544a<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u53ef\u80fd\u60a8\u7684<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7684<\/span><span style=\"font-family: Times;\"> GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e0a\u540c\u65f6\u6709\u591a\u4e2a\u811a\u672c<\/span><span style=\"font-family: Times;\">\/<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u5faa\u73af\u3002\u56e0\u6b64\uff0c\u5982\u679c<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u68c0\u6d4b\u5230\u67d0\u4e2a\u9488\u811a\u88ab\u8bbe\u7f6e\u4e3a\u5176\u5b83\u7528\u9014\u800c\u975e\u9ed8\u8ba4\u7684\u72b6\u6001\uff08\u9ed8\u8ba4\u4e3a\u8f93\u5165\uff09\uff0c\u60a8\u4f1a\u5728\u5c1d\u8bd5\u914d\u7f6e\u67d0\u811a\u672c\u65f6\u5f97\u5230\u8b66\u544a\u6d88\u606f\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u7981\u7528\u8be5\u8b66\u544a\u6d88\u606f\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.setwarnings(False)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u914d\u7f6e\u901a\u9053<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u60a8\u9700\u8981\u4e3a\u6bcf\u4e2a\u7528\u4e8e\u8f93\u5165\u6216\u8f93\u51fa\u7684\u9488\u811a\u914d\u7f6e\u901a\u9053\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u914d\u7f6e\u4e3a\u8f93\u5165\u7684\u901a\u9053\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.setup(channel, GPIO.IN)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\uff08\u901a\u9053\u7f16\u53f7\u662f\u57fa\u4e8e\u60a8\u6240\u4f7f\u7528\u7684\u7f16\u53f7\u7cfb\u7edf\u6240\u6307\u5b9a\u7684\uff08<\/span><span style=\"font-family: Times;\">BOARD <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6216<\/span><span style=\"font-family: Times;\"> BCM<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u3002\uff09<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u66f4\u591a\u5173\u4e8e\u8f93\u5165\u901a\u9053\u7684\u8fdb\u9636\u4fe1\u606f\u53ef\u4ee5\u5728<a title=\"\u4f7f\u7528 RPi.GPIO \u6a21\u5757\u7684\u8f93\u5165\uff08Input\uff09\u529f\u80fd\" href=\"http:\/\/shumeipai.nxez.com\/2016\/09\/28\/rpi-gpio-module-inputs.html\" target=\"_blank\"><span style=\"color: #3390ca;\">\u8fd9\u91cc<\/span><\/a>\u627e\u5230\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u914d\u7f6e\u4e3a\u8f93\u51fa\u7684\u901a\u9053\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.setup(channel, GPIO.OUT)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\uff08\u901a\u9053\u7f16\u53f7\u662f\u57fa\u4e8e\u60a8\u6240\u4f7f\u7528\u7684\u7f16\u53f7\u7cfb\u7edf\u6240\u6307\u5b9a\u7684\uff08<\/span><span style=\"font-family: Times;\">BOARD <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6216<\/span><span style=\"font-family: Times;\"> BCM<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u3002\uff09<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u60a8\u8fd8\u53ef\u4ee5\u6307\u5b9a\u8f93\u51fa\u901a\u9053\u7684\u521d\u59cb\u503c\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.setup(channel, GPIO.OUT, initial=GPIO.HIGH)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u8f93\u5165<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u8bfb\u53d6<\/span><span style=\"font-family: Times;\"> GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u9488\u811a\u7684\u503c\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.input(channel)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\uff08\u901a\u9053\u7f16\u53f7\u662f\u57fa\u4e8e\u60a8\u6240\u4f7f\u7528\u7684\u7f16\u53f7\u7cfb\u7edf\u6240\u6307\u5b9a\u7684\uff08<\/span><span style=\"font-family: Times;\">BOARD <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6216<\/span><span style=\"font-family: Times;\"> BCM<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u3002\uff09\u8fd9\u5c06\u8fd4\u56de<\/span><span style=\"font-family: Times;\"> 0 \/ GPIO.LOW \/ False <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6216\u8005<\/span><span style=\"font-family: Times;\"> 1 \/ GPIO.HIGH \/ True<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u8f93\u51fa<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u8bbe\u7f6e<\/span><span style=\"font-family: Times;\"> GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u9488\u811a\u7684\u8f93\u51fa\u72b6\u6001\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.output(channel, state)<br \/>\n<\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\uff08\u901a\u9053\u7f16\u53f7\u662f\u57fa\u4e8e\u60a8\u6240\u4f7f\u7528\u7684\u7f16\u53f7\u7cfb\u7edf\u6240\u6307\u5b9a\u7684\uff08<\/span><span style=\"font-family: Times;\">BOARD <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6216<\/span><span style=\"font-family: Times;\"> BCM<\/span><span style=\"font-family: \u5b8b\u4f53;\">\uff09\u3002\uff09<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u72b6\u6001\u53ef\u4ee5\u4e3a<\/span><span style=\"font-family: Times;\"> 0 \/ GPIO.LOW \/ False <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u6216\u8005<\/span><span style=\"font-family: Times;\"> 1 \/ GPIO.HIGH \/ True<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: \u5b8b\u4f53;\">\u6e05\u7406<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u5728\u4efb\u4f55\u7a0b\u5e8f\u7ed3\u675f\u540e\uff0c\u8bf7\u517b\u6210\u6e05\u7406\u7528\u8fc7\u7684\u8d44\u6e90\u7684\u597d\u4e60\u60ef\u3002\u4f7f\u7528<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e5f\u540c\u6837\u9700\u8981\u8fd9\u6837\u3002\u6062\u590d\u6240\u6709\u4f7f\u7528\u8fc7\u7684\u901a\u9053\u72b6\u6001\u4e3a\u8f93\u5165\uff0c\u60a8\u53ef\u4ee5\u907f\u514d\u7531\u4e8e\u77ed\u8def\u610f\u5916\u635f\u574f\u60a8\u7684<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u9488\u811a\u3002\u6ce8\u610f\uff0c\u8be5\u64cd\u4f5c\u4ec5\u4f1a\u6e05\u7406\u60a8\u7684\u811a\u672c\u4f7f\u7528\u8fc7\u7684<\/span><span style=\"font-family: Times;\"> GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u901a\u9053\u3002<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u5728\u60a8\u7684\u811a\u672c\u7ed3\u675f\u540e\u8fdb\u884c\u6e05\u7406\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/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: #323e4e; font-size: 13pt;\"><strong><span style=\"font-family: Arial;\">Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4fee\u8ba2\u7248\u672c\u548c<\/span><span style=\"font-family: Arial;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7248\u672c<\/span><span style=\"font-family: Arial;\"><br \/>\n<\/span><\/strong><\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u68c0\u6d4b<\/span><span style=\"font-family: Times;\"> Raspberry Pi <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4e3b\u677f\u7684\u4fee\u8ba2\u7248\u672c\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.RPI_REVISION<br \/>\n<\/span><\/p>\n<p><span style=\"color: #333a42; font-size: 11pt;\"><span style=\"font-family: \u5b8b\u4f53;\">\u68c0\u6d4b<\/span><span style=\"font-family: Times;\"> RPi.GPIO <\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7684\u7248\u672c\uff1a<\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #f7f7f7;\"><span style=\"color: #333333; font-family: Consolas; font-size: 10pt;\">GPIO.VERSION<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 \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u539f\u6587\u5730\u5740\uff1a<\/span><span style=\"color: #3390ca;\"><span style=\"font-family: Times;\">RPi.GPIO module basics<span style=\"color: #333a42;\"><br \/>\n<\/span><\/span><span style=\"font-family: \u5b8b\u4f53;\">\u9879\u76ee\u5730\u5740\uff1a<\/span><span style=\"font-family: Times;\">RPi.GPIO<span style=\"color: #333a42;\"><br \/>\n<\/span><\/span><span style=\"font-family: \u5b8b\u4f53;\">\u539f\u6587\u7ffb\u8bd1\uff1a<\/span><span style=\"font-family: Times;\">dreamcolor.net<span style=\"color: #333a42;\"><br \/>\n<\/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 title=\"\u6811\u8393\u6d3e\u5b9e\u9a8c\u5ba4\" href=\"http:\/\/shumeipai.nxez.com\/\"><span style=\"color: #3390ca;\">\u6811\u8393\u6d3e\u5b9e\u9a8c\u5ba4<\/span><\/a><\/span><span style=\"font-family: Times;\"><br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u94fe\u63a5\u5730\u5740\uff1a<\/span><span style=\"color: #3390ca; font-family: Times;\">http:\/\/shumeipai.nxez.com\/2016\/09\/28\/rpi-gpio-module-basics.html<span style=\"color: #333a42;\"><br \/>\n<\/span><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RPi.GPIO \u6a21\u5757\u7a0b\u5e8f\u5305\u63d0&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-294","post","type-post","status-publish","format-standard","hentry","category-reapberry"],"_links":{"self":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/294"}],"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=294"}],"version-history":[{"count":0,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"wp:attachment":[{"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}