流水灯 import RPi.GPIO as GPIO import time pin = 11,12,13 def setup(): GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(pin,GPIO.OUT) def lsd(): for i in pin: GPIO.output(i,True);time.sleep(0.5) for i in reversed(pin): GPIO.output(i,False);time.sleep(0.5) if __name__=='__main__': setup() try: while True: lsd() except KeyboardInterrupt: GPIO.cleanup()