Stormer97

simply python GPIO script

Apr 22nd, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import RPi.GPIO as GPIO # import the GPIO module
  2.  
  3. GPIO.setmode(GPIO.BCM) # sets the mode to BCM (meaning that pin 17 refers to th$
  4. GPIO.setup(17, GPIO.OUT) # marks pin 17 as an output pin
  5. GPIO.output(17, True) # sets pin 17 to true. Since pin 17 (GPIO 11) is marked a$
  6.  
  7. # you can just ignore this try except block, it is essentially the same as 'pau$
  8.  
  9. try:
  10.         foobar = input("press enter to exit")
  11. except SyntaxError:
  12.         pass
  13. GPIO.output(17, False) # turns pin 17 back off
  14.  
  15. #note, you must have your LED properly connectect your LED to pin 17 (GPIO 11)
  16. #also, you MUST run this script as root. you can do this byy typing the followi$
  17. # 'cd [wherever you saved this script]'
  18. # 'sudo python gpio-test.py'
  19. #this should run the script. If this does not work, post on the schoology threa$
Advertisement
Add Comment
Please, Sign In to add comment