Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. import time
  2. import RPi.GPIO as GPIO
  3.  
  4. MY_PIN = 2
  5.  
  6. GPIO.setmode(GPIO.BOARD)
  7.  
  8. GPIO.setup(MY_PIN, GPIO.IN)
  9.  
  10. try:
  11. while 1:
  12. if GPIO.input(MY_PIN) == GPIO.LOW:
  13. print "Signal is LOW"
  14. else:
  15. print "Signal is HIGH"
  16.  
  17. time.sleep(0.1)
  18.  
  19. except KeyboardInterrupt:
  20. pass
  21.  
  22. GPIO.cleanup()
  23.  
  24. print "BYE!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement