Hello
I am trying to use a PCF8574 I/O expander with an Arduino Uno
The wiring is very simple (see the attached picture).
The program is pasted later in this post
When I run this program, the yellow led is kept off (it should blink), but the led 13 (the led on the Uno board) blinks. If you look at the program, you'll see this means that the function Wire.endTransmission() returns 2, ie "received NACK on transmit of address "
I double-checked the connections, I replaced the PCF8574, I succeeded in controlling a led with pins A4 and A5 (checking the eventuality of a pb with the Arduino).
I there anything I does not undestand ?
Thanks for your help !
the program:
#include <Wire.h>
int x=0;
byte y=255;
int led = 13;
void setup()
{
Wire.begin();
pinMode(led, OUTPUT);
}
void loop()
{
Wire.beginTransmission(32); //Begin the transmission to PCF8574
Wire.write(y); //Send 255, this should put on the big yellow led
int status = Wire.endTransmission(); //End the Transmission
if ( status == 2 ) // If error 2
{
digitalWrite(led, HIGH); // led in arduino board is on
}
delay(2000); // wait 2 s
digitalWrite(led, LOW); // led off
delay(200); // wait .2s
Wire.beginTransmission(32);
Wire.write(x); // send 0, this should put the big yellow led off
Wire.endTransmission();
if ( status == 2 )
{
digitalWrite(led, HIGH);
}
delay(2000);
digitalWrite(led, LOW);
delay(200);
}