Category:IO Expander
- PCF8574 / PCF8575 - I2C - common used for 1602
- MCP23008 - I2C - 8-Bit I/O Expander with Serial Interface, - arduino library
- MCP23017 - I2C - 16-Bit I/O Expander with Serial Interface,
PCF8575 Demo Code
Use Wire.write(B00000000); to write value to the pins.
#include <Wire.h>
byte address = 0x20; // address of PCF8575 with A0-A2 connected to GND "B01000000"
byte input; // variable to receive the two bytes
byte c; // first of the two bytes to read
byte d; // second of the two bytes to read
int led = 13;
void setup()
{
Wire.begin(); // join i2c bus
Serial.begin(9600); // used to Debug , Thanks PaulS
pinMode(led, OUTPUT);
}
void loop(){
input = Wire.requestFrom(0x20,2);
c = Wire.read();
d = Wire.read();
Wire.endTransmission();
if(bitRead(d,6) == 0) {
digitalWrite(led, LOW);
delay(1000);
}
else {
digitalWrite(13, HIGH);
}
Serial.println(c, BIN);
delay(100);
Serial.println(d,BIN);
} // send the data
Demo code
- PCF8574 C51, avr, stm8 demo code - File:PCF8574-IO-Expansion-Board-code.zip