Smart Home Automation Forum
[Arduino source code for KC868-A256]-01 ADC_INOUT - 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-A256 (https://www.kincony.com/forum/forumdisplay.php?fid=44)
+--- Thread: [Arduino source code for KC868-A256]-01 ADC_INOUT (/showthread.php?tid=2716)



[Arduino source code for KC868-A256]-01 ADC_INOUT - KinCony Support - 03-22-2023

Code:
/*ADC Code for KC868-A256*/
#include "Arduino.h"

#define ANALOG_A1   36        // IO36 
#define ANALOG_A2   39        // IO39   
#define ANALOG_A3   34        // IO34   
#define ANALOG_A4   35        // IO35   
void setup()
{
    Serial.begin(115200);
    delay(1000);

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

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

}