Smart Home Automation Forum
A24 arduino demo source code-03-anlog input (ADC) - 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-03-anlog input (ADC) (/showthread.php?tid=3794)



A24 arduino demo source code-03-anlog input (ADC) - KinCony Support - 12-07-2023

Code:
#include "Arduino.h"

#define ANALOG_A1   35       
#define ANALOG_A2   34         
#define ANALOG_A3   39        
#define ANALOG_A4   36        
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("Current Reading A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));delay(500);}
  if(analogRead(ANALOG_A2)!=0)
    {  Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));delay(500);}
  if(analogRead(ANALOG_A3)!=0)
    {  Serial.printf("Current Reading A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));delay(500);}
  if(analogRead(ANALOG_A4)!=0)
    {  Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));delay(500);}

}