Code:
#include "Arduino.h"
#include "PCF8575.h"
#define delaytime 200
PCF8575 pcf8575_IN1(0x24,16,5);
PCF8575 pcf8575_IN2(0x25,16,5);
void setup()
{
Serial.begin(115200);
delay(100);
/**************************************************************/
pcf8575_IN1.begin();
pcf8575_IN2.begin();
for (int a=0;a<=15;a++)
{
pcf8575_IN1.pinMode(a,INPUT);
}
for (int a=0;a<=7;a++)
{
pcf8575_IN2.pinMode(a,INPUT);
}
/*************************************/
}
void loop()
{
delay(delaytime);
for(int a=0;a<=15;a++){
if (pcf8575_IN1.digitalRead(a)==0) Serial.printf(("KEY %d PRESSED\n"),a+1);
}
for(int a=0;a<=7;a++){
if (pcf8575_IN2.digitalRead(a)==0) Serial.printf(("KEY %d PRESSED\n"),a+17);
}
}