树莓派点亮LED灯
树莓派点亮LED灯
代码:
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library from time import sleep # Import the sleep function from the time module GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numbering GPIO.setup(11, GPIO.OUT, initial=GPIO.LOW) # Set pin 11 to be an output pin and set initial value to low (off). Note:Pins number read from LEFT to RIGHT, from TOP till BOTTOM.
while True: # Run forever GPIO.output(11, GPIO.HIGH) # Turn on sleep(0.5) # Sleep for 0.5 second GPIO.output(11, GPIO.LOW) # Turn off sleep(0.5) # Sleep for 0.5 second
Operation in Command Line Interface:
Run programme:python Led_Blink-1.py Stop running:ctrl+Z