Created
February 2, 2016 12:56
-
-
Save thisMagpie/71f848fc08314cbce14c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 webiopi | |
from webiopi.devices.digital import PCF8574A | |
mcp = PCF8574A(slave=0x38) | |
GPIO = webiopi.GPIO # Assign webiopi library to GPIO object | |
LED0 = 0 # Set PCF8574 GPIO pin 0 to connect to the LED (negative logic) | |
mcp.setFunction(LED0, GPIO.OUT) #Set Pin 0 as output | |
mcp.digitalWrite(LED0, GPIO.LOW) # Turn on the LED for the first time | |
""" | |
Function to toggle logic | |
""" | |
def toggleLED0(): | |
while True: # Always run loop | |
value = not mcp.digitalRead(LED0) # Assign opposite of current state (i.e. high or low) to value | |
mcp.digitalWrite(LED0, value) # Write assigned value to GPIO | |
webiopi.sleep(0.10) # Wait 2 seconds | |
toggleLED0() # Call toggle function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment