2016年3月20日 星期日

Raspberry pi 用 python 控制GPIO

Python 2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BOARD)
>>> GPIO.setup(5,GPIO.OUT)
>>> GPIO.output(5,True)
>>> GPIO.output(5,False)
>>> GPIO.setup(29,GPIO.OUT)  # 29 是指GPIO腳位 對應 GPIO5 ;要查看腳位表
__main__:1: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
>>> GPIO.setwarnings(False)
>>> GPIO.setup(29,GPIO.OUT)
>>> GPIO.output(29,False) # 即可控制該腳位ON-OFF
>>> GPIO.output(29,True)

可與BLYNK 同時控制GPIO腳位ON-OFF不會相衝
RASPBERRY 內建 PYTHON 2.7.9 AND GPIO MODEL

沒有留言: