Jump to content
Electronics-Lab.com Community

Recommended Posts

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 message

 
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...