Smart Home Automation Forum
A24 arduino demo source code-02-digital input - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KinCony A24 (https://www.kincony.com/forum/forumdisplay.php?fid=56)
+--- Thread: A24 arduino demo source code-02-digital input (/showthread.php?tid=3793)



A24 arduino demo source code-02-digital input - KinCony Support - 12-07-2023

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);
  }
 
}