AED 7.35
Description
The PCF8574 is an 8-bit I / O port expander connected via an I2C bus. if you have ever suffered from "pin deficiency" in one of your Projects you know what is meant.
Since the job of the PCF8574 is to expand the IO capabilities of a microcontroller, we can use it with our Arduino UNO board to increase the digital IO count to 21. The IO port pins can be used as either input or output
Specifications:
Number of I/Os: 8
Features Interrupt: pin
Supply voltage (Min): (V)2.5
Supply voltage (Max): (V)6
Addresses: 8
Frequency (Max): (kHz)100
Operating temperature range: (C)-40 to 85
PCF8574 Pinout:
Pin Number |
Pin Name |
Description |
1, 2, 3 | A0, A1, A2 |
Address Inputs |
4, 5, 6, 7, 9, 10, 11, 12 |
P0 – P7 |
Input / Output Port |
8 |
GND |
Ground |
13 |
INT |
Interrupt Output (Must be pulled high to VCC) |
14 |
SCL |
Serial Clock of I2C (Must be pulled high to VCC) |
15 |
SDA |
Serial Data of I2C (Must be pulled high to VCC) |
16 |
VCC |
Voltage Supply |
PCF8574 Connections with Arduino :
Since the PCF8574 works on I2C Communications, we have to use the I2C Pins of the Arduino to control the IO Pins of the IC. Pins A4 and A5 of Arduino UNO are the I2C Pins where A4 is the SDA (Data) pin and A5 is the SCL (Clock) pins.
Connect these pins to the corresponding SDA and SCL Pins of the PCF8574 Board. Now, connect the VCC and GND Pins to the +5V and GND pins of the Arduino.
Code for getting the I2C Address of the PCF8574 IC:
First, we have to figure out the I2C bus slave address of the PCF8574 IC. Use the following code to calculate the address of the. when the A0, A1, and A2 pins are connected to LOW.
#include
void setup()
{
Wire.begin();Serial.begin(9600);
while (!Serial);
}void loop()
{
byte error, address;
int I2CDevices;Serial.println(“Scanning for I2C Devices…”);
I2CDevices = 0;
for (address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
error = Wire.endTransmission();if (error == 0)
{
Serial.print(“I2C device found at address 0x”);
if (address < 16)
Serial.print(“0″);
Serial.print(address, HEX);
Serial.println(” !”);I2CDevices++;
}
else if (error == 4)
{
Serial.print(“Unknown error at address 0x”);
if (address < 16)
Serial.print(“0”);
Serial.println(address, HEX);
}}
if (I2CDevices == 0)
Serial.println(“No I2C devices found\n”);
else
Serial.println(“****\n”);delay(5000);
}
the address turned out to be 0x20 (it can be different). So, we have to use this address in the actual code.
The Library of the PCF8574 IC:
if everything was good till now you can use this library to simply control the IC in your code Click Here to download It.
now to learn morehttps://github.com/xreef/PCF8574_library about the previous library Click Here.