Files
python-gpiozero/gpio_components/output_devices.py
Dave Jones b87bb0c4c3 Minor clean-up
Expand gitignore to include the usual py developing stuff, add an
__init__ to make this a legitimate package, move GPIO initialization
into the package init, import all stuff from input and output devices in
the package to enable the access demonstrated in the example, remove a
duplicate method from LightSensor, and make motion_detected a property
(for consistency with is_active which it presumably parallels).
2015-09-15 08:43:13 +01:00

26 lines
362 B
Python

from RPi import GPIO
class OutputDevice(object):
def __init__(self, pin):
self.pin = pin
GPIO.setup(pin, GPIO.OUT)
def on(self):
GPIO.output(self.pin, True)
def off(self):
GPIO.output(self.pin, False)
class LED(OutputDevice):
pass
class Buzzer(OutputDevice):
pass
class Motor(OutputDevice):
pass