Revision c5ac7e4c
Added by dsorber over 13 years ago
| 525.743/code/test scripts/button_LED.py | ||
|---|---|---|
|
|
||
|
import RPIO
|
||
|
|
||
|
CURRENT = 23
|
||
|
outputs = [23, 24, 25, 8, 7]
|
||
|
out_iterator = itertools.cycle(outputs)
|
||
|
CURRENT = outputs[0]
|
||
|
|
||
|
def main():
|
||
|
# Use the BCM addressing scheme
|
||
| ... | ... | |
|
# Setup switch interrupt with debounce
|
||
|
RPIO.add_interrupt_callback(22, switch_callback, edge='rising',
|
||
|
pull_up_down=RPIO.PUD_DOWN, threaded_callback=True,
|
||
|
debounce_timeout_ms=100)
|
||
|
debounce_timeout_ms=150)
|
||
|
|
||
|
print 'Okay, waiting for interrupts... %d' % CURRENT
|
||
|
print 'Okay, waiting for interrupts...'
|
||
|
|
||
|
# Main (blocking) loop
|
||
|
while True:
|
||
|
RPIO.wait_for_interrupts()
|
||
|
|
||
|
def switch_callback(gpio_id, val):
|
||
|
global CURRENT
|
||
|
print 'Switch activated! %s --- %s' % (gpio_id, val)
|
||
|
|
||
|
print outputs
|
||
|
|
||
|
# Turn off current LED
|
||
|
RPIO.output(CURRENT, False)
|
||
|
|
||
|
# Get next output and turn it on
|
||
|
CURRENT = out_iterator.next()
|
||
|
print CURRENT
|
||
|
RPIO.output(CURRENT, True)
|
||
|
|
||
|
|
||
Added a couple more scripts including one to talk to the 7 segment display.