Advertisement
schuetz

hallInterrupt.py

May 3rd, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2.  
  3. hall_sensor_pin = 24
  4.  
  5. GPIO.setmode( GPIO.BCM )
  6. GPIO.setup( hall_sensor_pin, GPIO.IN, GPIO.PUD_UP)
  7.  
  8. print "linker hall_sensor pin 24"
  9.  
  10. def hallCallback(gpioNum):
  11.     print("fallende Flanke auf GPIO %s"%gpioNum)
  12.  
  13. GPIO.add_event_detect(hall_sensor_pin, GPIO.FALLING, callback=hallCallback, bouncetime=200)
  14.  
  15. try:
  16.     while True:
  17.         print "Warte..."
  18.         raw_input()
  19.        
  20. except KeyboardInterrupt:
  21.     print " bye bye "
  22.        
  23. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement