07-07-2024, 06:12 PM
In Definition:
PCF8575 pcf8575_in(0x24,15,4);
PCF8575 pcf8575_out(0x24,15,4);
In Setup:
for(int i=0;i<16;i++)
{
pcf8575_in.pinMode(i,INPUT);
}
pcf8575_in.begin();
for(int i=0;i<16;i++)
{
pcf8575_out.pinMode(i,OUTPUT);
}
pcf8575_out.begin();
I set i2c address for digital input like this: PCF8575 pcf8575_in(0x24,15,4);
and i2c address for relay output like this: PCF8575 pcf8575_out(0x24,15,4);
When I'm making all relay output pins to LOW with this:
for(int i=0;i<16;i++){
pcf8575_out.digitalWrite(i, LOW);
}
Its automatically making digital input pins to LOW as well in the loop:
for(int i=0;i<16;i++)
{
int piDigital = pcf8575_in.digitalRead(i); // read P(i)
if(piDigital==0)
{
Serial.print("KEY ");
Serial.print(i+1);
Serial.println(" PRESSED");
}
}
When I'm making all relay output pins to LOW, why is it making the digital input pins to LOW ?
PCF8575 pcf8575_in(0x24,15,4);
PCF8575 pcf8575_out(0x24,15,4);
In Setup:
for(int i=0;i<16;i++)
{
pcf8575_in.pinMode(i,INPUT);
}
pcf8575_in.begin();
for(int i=0;i<16;i++)
{
pcf8575_out.pinMode(i,OUTPUT);
}
pcf8575_out.begin();
I set i2c address for digital input like this: PCF8575 pcf8575_in(0x24,15,4);
and i2c address for relay output like this: PCF8575 pcf8575_out(0x24,15,4);
When I'm making all relay output pins to LOW with this:
for(int i=0;i<16;i++){
pcf8575_out.digitalWrite(i, LOW);
}
Its automatically making digital input pins to LOW as well in the loop:
for(int i=0;i<16;i++)
{
int piDigital = pcf8575_in.digitalRead(i); // read P(i)
if(piDigital==0)
{
Serial.print("KEY ");
Serial.print(i+1);
Serial.println(" PRESSED");
}
}
When I'm making all relay output pins to LOW, why is it making the digital input pins to LOW ?