The pin layout for the PCF8574P is as follows:
A0 1 address input 0
A1 2 address input 1
A2 3 address input 2
P0 4 quasi-bidirectional I/O 0
P1 5 quasi-bidirectional I/O 1
P2 6 quasi-bidirectional I/O 2
P3 7 quasi-bidirectional I/O 3
VSS 8 supply ground
P4 9 quasi-bidirectional I/O 4
P5 10 quasi-bidirectional I/O 5
P6 11 quasi-bidirectional I/O 6
P7 12 quasi-bidirectional I/O 7
INT 13 interrupt output (active LOW)
SCL 14 serial clock line
SDA 15 serial data line
VDD 16 supply voltage
As we have learned, each slave IC communicating with I2C needs an address. The address is one byte long, but we have only seven bits to send as the eighth bit is an read/write indication. For the PCF8574P the address always starts with 0100, leaving us 3 bits to set. This allows us to have 8 PCF8574P slaves connected in one I2C network, because the bits 1,1,1 = 7. So we have 0 - 7 = 8 possible settings. The three bits are set by connecting the pins a0 - a2 on either Vcc (1) or ground (0). For example if I have set A0 = 1, A1=0, A2=0 my address to control the PCF8574P would be: 0100001.
P0 through P7 are the input/output pins much like the ones on the Arduino. VSS is the ground connection pin, while Vdd connects to the voltage supply. INT allows you to disable the PCF8574P by placing a HIGH voltage on the pin. SCL and SDA are the familiar I2C pins which should connect to the Arduino.
The following circuit will require the following components:
1 x Arduino Duemilanove
1 x Red LED
1 x PCF8574P
1 x 680 Ohm resistor (blue, gray, brown, gold)
2 x 1.5 KOhm resistor (brown, green, red, gold) You can use up to 2 KOhm. I put 1 KOhm + 680 Ohm in series instead.
#define CARD_ADR (0x4 << 3 | 0x0) // address 0100000
/* Include the wire header */
void setup ()
/* setup mwiring */
void loop ()
/* set all pins off */
/* set all pins on */
That's it for today, next time we will be completing the project!