Last active
December 21, 2015 01:59
-
-
Save adammelancon/6231840 to your computer and use it in GitHub Desktop.
A small class I wrote to easily turn on and off the relay on a PiFace for the Raspberry Pi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import piface.pfio as pfio | |
pfio.init() | |
# A class to controll the relay | |
class Bpress: | |
def relayon(self): | |
pfio.digital_write(1,1) | |
print "Turning on relay!" | |
while True: | |
if pfio.digital_read(0) == 0: | |
return | |
def relayoff(self): | |
pfio.digital_write(1,0) | |
print "Turning off relay!" | |
while True: | |
if pfio.digital_read(1) == 0: | |
return | |
piface = Bpress() | |
# Relay Test | |
piface.relayon() | |
time.sleep(3) | |
piface.relayoff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment