This is the PCF8574AP consists of an 8-bit quasi-bidirectional port and an i2C Serial Bus Interface. The PCF8574AP has a low current consumption and includes latched output with HIGH consumption and include latched output with high current drive capability for directly driving LEDS. It also possesses an interrupt which can be connected to the interrupt logic of the Microcontroller, by sending an interrupt signal on this line, the remote I/O can inform the microcontroller if there is incoming data on its ports without having to communicate via the i2C bus. This means that the PCF8574 can remain a simple slave device. This device is useful when you want to extend the IO pins of your Microcontroller using i2C Serial Communication Bus or SPI.
The Integrated PCF8574AP providing 8 ports INPUT / OUTPUT ports that can be manage using i2C serial communication. The following diagram below shows how to wire the PCF8574AP using OUTPUT series of LED served as indicator of our IO pins there are two diagram shows below one is the LED output and the tactile push button switch served as INPUT.
Required Component
- Arduino Microcontroller, Teensy (TeensyDuino Integrated), ESP8266, STMXX
- PCF8574AP Chip / PCF8574AP Board
- Solder Less Bread Board
- Jumper Wire
Wiring Guide
The first code below will test the circuit allow you to turn off and on a series of connected LED’s to IO ports.
Source Code for OUTPUT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include <Wire.h> int core = 1000; void setup () { Serial.begin(9600); Serial.println("14CORE | PCF8574AP IO EXPANSION TEST CODE"); Serial.println("-----------------------------------------"); Serial.println("Begin..."); Wire.begin (); delay(core); } void loop () { Wire.beginTransmission (0x38); //Set P0 pin to logic level HIGH Wire.write ((byte) 0b00000001); //Send byte to write 0b00000001 Wire.endTransmission(); //Set to end transmission delay(core); Wire.beginTransmission (0x38); //Start begin transmission to address 0x38 set PO logic level LOW Wire.write((byte) 0b00000000); //Send a byte. Wire.endTransmission (); //End transmissions. delay (core); Wire.beginTransmission (0x38); Wire.write((byte) 0b11111111); //Set all pin P0, P1, P2, P3, P4, P5, P6, P7 to logic level HIGH Wire.endTransmission (); delay(core); Wire.beginTransmission (0x38); Wire.write((byte) 0b00000000); //Set all pin P0, P1, P2, P3, P4, P5, P6, P7 to logic level LOW Wire.endTransmission (); delay(core); } |
Source Code for INPUT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include <Wire.h> int core1 = 6000; int core2 = 1000; void setup () { Serial.begin (9600); Serial.println("14CORE | PCF8574AP IO EXPANSION FOR INPUT"); Serial.println("-----------------------------------------"); Serial.println("Begin..."); delay(core1); Wire.begin (); delay(core2); } void loop () { Wire.requestFrom (0x38,1); if (Wire.available ()) { Serial.print("IO : "); Serial.print(Wire.read (), BIN); } delay (core2); } |
Downloads
Download PCF8574AP Datasheet | PDF