Project

General

Profile

Download (937 Bytes) Statistics
| Branch: | Tag: | Revision:
import sys

import RPIO

class LED(object):

def __init__(self, gpio_num):
self.gpio_num = gpio_num
self.state = False

# Use the BCM addressing scheme
RPIO.setmode(RPIO.BCM)

# Configure GPIO as output and turn off
RPIO.setup(self.gpio_num, RPIO.OUT)
RPIO.output(self.gpio_num, False)

def on(self):
self.state = True
RPIO.output(self.gpio_num, True)

def off(self):
self.state = False
RPIO.output(self.gpio_num, False)

def toggle(self):
self.state = not self.state
RPIO.output(self.gpio_num, self.state)

def main():
import time

led1 = LED(23)
led2 = LED(7)
print 'Quick status LED unit test'
print 'Turning on LED1'
led1.on()
time.sleep(1)
print 'Turning on LED2'
led2.on()
time.sleep(1)
print 'Turning off LED1'
led1.off()
for ctr in xrange(0, 10):
time.sleep(1)
led1.toggle()
led2.toggle()
print 'Toggle iteration %d' % (ctr + 1)

if __name__ == '__main__':
sys.exit(main())

(11-11/12)