Revision 22b6f476
Added by dsorber over 13 years ago
| 525.743/code/test scripts/blinky_pattern.py | ||
|---|---|---|
|
import sys
|
||
|
import time
|
||
|
|
||
|
import RPi.GPIO as GPIO
|
||
|
import RPIO as GPIO
|
||
|
|
||
|
outputs = [23, 24, 25, 8, 7]
|
||
|
|
||
| 525.743/code/test scripts/button_LED.py | ||
|---|---|---|
|
import itertools
|
||
|
import sys
|
||
|
|
||
|
import RPIO
|
||
|
|
||
|
CURRENT = 23
|
||
|
outputs = [23, 24, 25, 8, 7]
|
||
|
out_iterator = itertools.cycle(outputs)
|
||
|
|
||
|
def main():
|
||
|
# Use the BCM addressing scheme
|
||
|
RPIO.setmode(RPIO.BCM)
|
||
|
|
||
|
# Setup input
|
||
|
RPIO.setup(22, RPIO.IN)
|
||
|
|
||
|
# Setup all five outputs
|
||
|
for gpio in outputs:
|
||
|
RPIO.setup(gpio, RPIO.OUT)
|
||
|
RPIO.output(gpio, False)
|
||
|
|
||
|
# 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)
|
||
|
|
||
|
print 'Okay, waiting for interrupts... %d' % CURRENT
|
||
|
|
||
|
# Main (blocking) loop
|
||
|
while True:
|
||
|
RPIO.wait_for_interrupts()
|
||
|
|
||
|
def switch_callback(gpio_id, val):
|
||
|
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()
|
||
|
RPIO.output(CURRENT, True)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
sys.exit(main())
|
||
| 525.743/code/test scripts/pushbutton.py | ||
|---|---|---|
|
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())
|
||
Started working on some simple test programs for the board.