root/software/525.743/code/bfcslib/pushbutton.py @ cd10f9a6
| 22b6f476 | dsorber | import sys
|
||
import RPIO
|
||||
def main():
|
||||
# Use the BCM addressing scheme
|
||||
RPIO.setmode(RPIO.BCM)
|
||||
| e376a628 | dsorber | # Setup pushbutton input
|
||
| 22b6f476 | dsorber | RPIO.setup(22, RPIO.IN)
|
||
RPIO.add_interrupt_callback(22, switch_callback, edge='both',
|
||||
pull_up_down=RPIO.PUD_DOWN, threaded_callback=False,
|
||||
debounce_timeout_ms=300)
|
||||
print 'Okay, waiting for interrupts...'
|
||||
while True:
|
||||
RPIO.wait_for_interrupts()
|
||||
def switch_callback(gpio_id, val):
|
||||
print 'Switch activated! %s --- %s' % (gpio_id, val)
|
||||
if __name__ == '__main__':
|
||||
| e45aa19e | dsorber | sys.exit(main())
|