标签:
1 import RPi.GPIO as GPIO 2 import time 3 4 channels = [16,18,22,24,26,19,21,23] 5 6 def init(): 7 GPIO.setmode(GPIO.BOARD) 8 for x in channels: 9 GPIO.setup(x,GPIO.OUT) 10 pass 11 12 def on(i): 13 GPIO.output(channels[i], GPIO.HIGH) 14 15 def off(i): 16 GPIO.output(channels[i], GPIO.LOW) 17 18 def ctrl(data): 19 for i in channels: 20 GPIO.output(i, data & 0x1) 21 data = data >> 1 22 pass 23 24 def test(): 25 for i in xrange(512): 26 ctrl(i) 27 time.sleep(0.1) 28 29 def clean(): 30 GPIO.cleanup()
调用
1 import led 2 3 led.init() 4 led.test() 5 led.clean()
标签:
原文地址:http://www.cnblogs.com/raddleoj/p/5187268.html