Revision 74eab0f1
Added by dsorber over 13 years ago
| 525.743/code/test scripts/relay.py | ||
|---|---|---|
|
|
||
|
import RPIO
|
||
|
|
||
|
def main():
|
||
|
|
||
|
if len(sys.argv) < 2:
|
||
|
print 'Error, you must specify at least one argument'
|
||
|
return
|
||
|
|
||
|
# Use the BCM addressing scheme
|
||
|
RPIO.setmode(RPIO.BCM)
|
||
|
from status_led import LED
|
||
|
|
||
|
# Setup output
|
||
|
RPIO.setup(17, RPIO.OUT)
|
||
|
|
||
|
if sys.argv[1] == '1':
|
||
|
class Relay(object):
|
||
|
|
||
|
def __init__(self):
|
||
|
# Use the BCM addressing scheme
|
||
|
RPIO.setmode(RPIO.BCM)
|
||
|
|
||
|
# Setup output for relay
|
||
|
RPIO.setup(17, RPIO.OUT)
|
||
|
RPIO.output(17, False)
|
||
|
|
||
|
# Instantiate the relay status LED (23)
|
||
|
self.led = LED(23)
|
||
|
|
||
|
def on(self):
|
||
|
self.led.on()
|
||
|
RPIO.output(17, True)
|
||
|
print 'Relay on'
|
||
|
else:
|
||
|
|
||
|
def off(self):
|
||
|
self.led.off()
|
||
|
RPIO.output(17, False)
|
||
|
print 'Relay off'
|
||
|
|
||
|
def main():
|
||
|
|
||
|
import time
|
||
|
|
||
|
relay = Relay()
|
||
|
print 'Quick relay unit test'
|
||
|
print 'Turning relay on...'
|
||
|
relay.on()
|
||
|
time.sleep(5)
|
||
|
print 'Okay that\'s enough of that'
|
||
|
relay.off()
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
Did a bit more work. The remote temperature readings are way off, I need to figure out why.