Guest User

led.py

a guest
Jan 12th, 2014
690
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. fobj = open("/root/status.txt","r+")
  3. import RPi.GPIO as GPIO
  4. import time
  5. GPIO.setwarnings(False)
  6. GPIO.setmode(GPIO.BOARD)
  7. GPIO.setup(7, GPIO.OUT)
  8. status=fobj.read()
  9. if status == "1":
  10.     GPIO.output(7, GPIO.LOW)
  11.     fobj.seek(0)
  12.     fobj.truncate()
  13.     fobj.write("0")
  14. elif status == "0":
  15.     GPIO.output(7, GPIO.HIGH)
  16.     fobj.seek(0)
  17.     fobj.truncate()
  18.     fobj.write("1")
  19. fobj.close()
RAW Paste Data