Read Anolog PIN A3,A4 - 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-A4 (https://www.kincony.com/forum/forumdisplay.php?fid=21) +--- Thread: Read Anolog PIN A3,A4 (/showthread.php?tid=2577) |
Read Anolog PIN A3,A4 - rha - 02-16-2023 Hi, i use this simple code for read value from pins anolog input (0-5V) PIN A3 and A4. At pin A3 connect 0V at pin A4 connect stable 2.5 V and reading value. #define ANALOG_PIN_A3 32 #define ANALOG_PIN_A4 33 void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(ANALOG_PIN_A3,INPUT); pinMode(ANALOG_PIN_A4,INPUT); } int analog_value_3 = 0; int analog_value_4 = 0; void loop() { // put your main code here, to run repeatedly: analog_value_3 = analogRead(ANALOG_PIN_A3); analog_value_4 = analogRead(ANALOG_PIN_A4); Serial.printf("Current reading on Pin (%d)=%d\n",ANALOG_PIN_A3,analog_value_3); Serial.printf("Current reading on Pin (%d)=%d\n",ANALOG_PIN_A4,analog_value_4); delay(2000); } At serial monitor i see this result Current reading on Pin (33)=1889 Current reading on Pin (32)=0 Current reading on Pin (33)=1872 Current reading on Pin (32)=0 Current reading on Pin (33)=1875 Current reading on Pin (32)=0 Current reading on Pin (33)=1875 Current reading on Pin (32)=0 Current reading on Pin (33)=1872 Current reading on Pin (32)=0 Current reading on Pin (33)=1920 Current reading on Pin (32)=0 Current reading on Pin (33)=1872 Current reading on Pin (32)=0 Current reading on Pin (33)=1873 Current reading on Pin (32)=0 Current reading on Pin (33)=1879 Current reading on Pin (32)=0 Current reading on Pin (33)=1872 Current reading on Pin (32)=0 Current reading on Pin (33)=1872 Current reading on Pin (32)=0 Current reading on Pin (33)=1873 Current reading on Pin (32)=0 Current reading on Pin (33)=1888 Current reading on Pin (32)=0 Current reading on Pin (33)=1871 Current reading on Pin (32)=0 Current reading on Pin (33)=1865 VALUE of PIN 4 (33) is NOT STABLE the value varies, it pulsates +/-20 or more, max 1920 , minimum 1865. It is normaly ? Can i solve it ? THX RHA RE: Read Anolog PIN A3,A4 - admin - 02-17-2023 Small changes are normal because analog input signals are very sensitive. |