cubieboard2使用GPIO驱动LED

1.安装python
2.安装python-dev sudo apt-get install python-dev
3.下载gpio驱动 wget http://dl.linux-sunxi.org/users/tom/pySUNXI-0.1.12.tar.gz
4.解包gpio tar zxf pySNXI-0.1.12.tar.gz
5.安装gpio python setup.py install
6.编写代码  blink.py
#!/user/bin/ python
import SUNXI_GPIO as GPIO
import time

RED_LED = GPIO.PD0

GPIO.init()
GPIO.setcfg(RED_LED, GPIO.OUT)

while True:
    GPIO.output(RED_LED, GPIO.HIGH)
    print 'high'
    time.sleep(1)
    GPIO.output(RED_LED, GPIO.LOW)
    print 'low'
time.sleep(1)

7.PD0接LED长灯脚,LED灯脚较短的接GND,随便加个限流电阻。
8.执行程序 sudo python blink.py(或者加权限后直接执行blink.py程序)

9.效果:

cubieboard2使用GPIO驱动LED_第1张图片

你可能感兴趣的:(python,pi,cubieboard,raspberry,led,GPIO)