|
import sys
|
|
|
|
import RPIO
|
|
|
|
from status_led import LED
|
|
|
|
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)
|
|
|
|
def off(self):
|
|
self.led.off()
|
|
RPIO.output(17, False)
|
|
|
|
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__':
|
|
sys.exit(main())
|
|
|