root/525.743/code/test scripts/pushbutton.py @ c5ac7e4c
| 22b6f476 | dsorber | import sys
|
|
import RPIO
|
|||
def main():
|
|||
# Use the BCM addressing scheme
|
|||
RPIO.setmode(RPIO.BCM)
|
|||
# Setup input
|
|||
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__':
|
|||
sys.exit(main())
|