Ejemplo n.º 1
0
"""
Intermitant issues with loop not restarting.
"""

import RPi.GPIO as GPIO
import time
import numpy as np
from webiopi.devices.digital.pcf8574 import PCF8574A

mcp = PCF8574A(slave=0x38)  # decimal 56

num_led = 4
LED_arr = np.arange(num_led)  # Set arr components as 0, 1, 2
SWITCH0 = mcp.setFunction(4, GPIO.IN)

for i in range(num_led):
    mcp.setFunction(LED_arr[i], GPIO.OUT)  # Set pin as an output

# Loop for ever
while True:
    if (mcp.digitalRead(4) == GPIO.LOW):  # Button pressed
        mcp.portWrite(15)  # Turn all LEDs of
        loop = True
        while loop:  # Wait for button to be pressed again
            time.sleep(0.2)  # Allow for finger to release from button
            mcp.digitalWrite(4, GPIO.HIGH)
            if (mcp.digitalRead(4) == GPIO.LOW
                ):  # Button pressed again so start looping again
                loop = False
                time.sleep(0.2)  # Allow for finger to release from button
        mcp.digitalWrite(4, GPIO.HIGH)
Ejemplo n.º 2
0
# Imports
import RPi.GPIO as GPIO
import time
from webiopi.devices.digital.pcf8574 import PCF8574A

# Setup chip
mcp = PCF8574A(slave=0x38)

# Set which PCF8574 GPIO pin is connected to the LED (negative logic)
LED0 = 0

# Setup GPIOs
mcp.setFunction(LED0, GPIO.OUT) #Set Pin as output

# Turn on the LED for the first time
mcp.digitalWrite(LED0, GPIO.LOW)
 
# Loop for ever
#    Insert your code here
# Include a delay 
time.sleep(0.10)
Ejemplo n.º 3
0
# Imports
import webiopi
from webiopi.devices.digital.pcf8574 import PCF8574A

# Retrieve GPIO lib
GPIO = webiopi.GPIO

# Setup chip
mcp = PCF8574A(0x38)

# Set which PCF8574 GPIO pin is connected to the LED
LED0 = 0

# Set pin as output
mcp.setFunction(LED0, GPIO.OUT)

# Turn on the LED
mcp.digitalWrite(LED0, GPIO.LOW)

# Insert your code here