Sai Shoby Posted October 13, 2020 Report Share Posted October 13, 2020 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 Quote Link to comment Share on other sites More sharing options...
HarryA Posted October 13, 2020 Report Share Posted October 13, 2020 What are you connecting the PCF8575 to? You most likely need to include some type of library. Quote Link to comment Share on other sites More sharing options...
Sai Shoby Posted October 14, 2020 Author Report Share Posted October 14, 2020 scl and Sda pins are connected to pic controller Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.