Here’s a short Python script to toggle an LED using GPIO.
#!/usr/bin/env python import RPi.GPIO as GPIO import time pin = 15 blinkSpeed = 1/5.0 #blink x times per second GPIO.setmode(GPIO.BOARD) GPIO.setup(pin, GPIO.OUT) try: while True: print('PIN {} is going HIGH'.format(pin)) GPIO.output(pin, GPIO.HIGH) time.sleep(blinkSpeed / 2.0) print('PIN {} is going LOW'.format(pin)) GPIO.output(pin, GPIO.LOW) time.sleep(blinkSpeed / 2.0) finally: print 'finally'