import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import sleep function from time module
GPIO.setmode(GPIO.BCM) # Use BCM numbering
GPIO.setwarnings(False) # Ingnore all GPIO warnings
GPIO.setup(23,GPIO.OUT) # Set GPIO 23 to be an output pin
while True: # Infinity loop
print "LED is on" # Display LED is ON on the screen
GPIO.output(23,GPIO.HIGH) # Turn on voltage
sleep(2) # Delay for 2secs
print "LED is off" # Display LED is OFF on the screen
GPIO.output(23,GPIO.LOW) # Turn off voltage
sleep(2) # Delay for 2secs
Comments