Skip to content

Instantly share code, notes, and snippets.

@electronut
Created June 18, 2013 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save electronut/5803155 to your computer and use it in GitHub Desktop.
Save electronut/5803155 to your computer and use it in GitHub Desktop.
blinking an LED with Raspberry Pi. LED is connected on pin 18 (GPIO5)
# blinking an LED with Raspberry Pi. LED is connected on pin 18 (GPIO5)
#
# run this as:
# sudo python test.py
#
# electronut.in
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(18, GPIO.OUT)
while True:
try:
GPIO.output(18, True)
time.sleep(0.5)
GPIO.output(18, False)
time.sleep(0.5)
except:
print 'exiting...'
# off
GPIO.output(18, False)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment