Hello,
I tried to use a PFC8574 I2C by doing as described on this page, but it does not seem to work.
I have tried changing the address but without any luck.
I also added debug code so that it write back to the serial line what it is doing.
Any suggestions?
Here is my code:
#include "Arduino.h"
#include "PCF8574.h"
const int iCtrlLed = 8;
// Set i2c address
//uint8_t sdaPin = 4;
//uint8_t sclPin = 5;
PCF8574 pcf8574(0x20);
void setup()
{
Serial.begin(9600);
// Set pinMode to OUTPUT
for (int i = 0; i < 8; i++) {
pcf8574.pinMode(i, OUTPUT);
}
pcf8574.begin();
pinMode(iCtrlLed, OUTPUT);
digitalWrite(iCtrlLed, LOW);
}
void loop()
{
static int pin = 0;
char buffer[20];
sprintf(buffer, "Pin: %d\n", pin);
Serial.print(buffer);
digitalWrite(iCtrlLed, HIGH);
pcf8574.digitalWrite(pin, HIGH);
delay(1000);
digitalWrite(iCtrlLed, LOW);
pcf8574.digitalWrite(pin, LOW);
delay(1000);
pin++;
if (pin > 7) {
pin = 0;
}
}