PCF8575

Sai Shoby

Oct 13, 2020
4
Joined
Oct 13, 2020
Messages
4
unsigned short PortP0 ;
unsigned short PortP1 ;

void main(){
{
I2C1_Init(100000); //100 KHz // join i2c bus
}
while(1)
{

I2C_Start();
I2c_Write(0x43); //Read Address

PortP0 = I2C_Read(0);
PortP1 = I2C_Read(0);
I2C_Stop();

if(PortP0 == 0b11100001) //Making Bit 0 high
{
I2C_Write(0x42);//Setting the Slave Address for PCF8575. Write Address
I2C_Write(0b11100000);// first 8bits
I2C_Write(0b11111110);// Turn on led on Bit0
}

}

}


Hi all,
I am trying to control switches in PCF8575 through I2C, when I press the switch which is connected in port0 in PCF8575, I want to glow the leds which i connect in port1 of pcf8575. i attached code. I cant able to read the switch status. Please help me to solve this. Switches are connected in po,p1,p2,p3,p4 with pull down resistors and leds are connected in p12,p13,p14,p15 with pull up resistors in pcf8575



modify_inline.gif


 
 

HarryA1

Mar 4, 2009
481
Joined
Mar 4, 2009
Messages
481
What are you connecting the PCF8575 to?  You most likely need to include some type of library.

 
Top