import RPi.GPIO as GPIO import time led = 23 GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(led,GPIO.OUT) print "CTRL+C = STOP program" try: while True: GPIO.output(led,GPIO.HIGH) time.sleep(0.5) GPIO.output(led,GPIO.LOW) time.sleep(0.5) except KeyboardInterrupt: GPIO.cleanup() # must be executed before program stop