
Monitor Digital Inputs
Digital Inputs
The eight digital inputs allow software applications running on the Raspberry Pi to monitor the status of external signals. The inputs can be connected to 12V signals (maximum 30V). The PCF8574 I2C device can be polled to monitor the inputs. When an input is greater then 6V, the device will report as "1" or ON and when less than 6V it will report a "0" or OFF.
Python Test Program
import smbus
import time
from os import system
bus=smbus.SMBus(1)
**** Digital Output
PCF8574=0x20
***** Digital Input
def PCF8574_input():
val = bus.read_byte(PCF8574)
return val
***** Initialize the devices
while True:
print "Input {0:b} ".format(PCF8574_input())
time.sleep(1)