Smart Home Automation Forum
[Arduino source code for KC868-M16]-02 -ADC_code - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-M16 / M1 / MB / M30 (https://www.kincony.com/forum/forumdisplay.php?fid=50)
+--- Thread: [Arduino source code for KC868-M16]-02 -ADC_code (/showthread.php?tid=2877)



[Arduino source code for KC868-M16]-02 -ADC_code - KinCony Support - 05-06-2023

[Arduino source code for KC868-M16]-02 -ADC_code
Code:
/*KC868-M16 Read A1 A2 A4 input*/

#include "Arduino.h"
#include "PCF8574.h"         

#define ANALOG_A1   36       
#define ANALOG_A2   34     
#define ANALOG_A4   39     


void setup()
{
    Serial.begin(115200);

  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);
  pinMode(ANALOG_A4,INPUT);
}

void loop()
{
  if(analogRead(ANALOG_A1)!=0){
    Serial.printf("Current Reading A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));
  }
   if(analogRead(ANALOG_A2)!=0){
    Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
   }
   if(analogRead(ANALOG_A4)!=0){
    Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
   }
   delay(100);
 
}