Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[arduino code examples for A16v3]-03 Read analog input ports value
#1
Code:
#include "Arduino.h"

#define ANALOG_A1   4
#define ANALOG_A2   6
#define ANALOG_A3   7
#define ANALOG_A4   5

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()
{
  delay(1000);
  Serial.printf("Current Reading A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));
  Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
  Serial.printf("Current Reading A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));
  Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
}
arduino ino file download:
.zip   3-analog-input.zip (Size: 415 bytes / Downloads: 11)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   3-analog-input.ino.merged.zip (Size: 184.51 KB / Downloads: 8)
Reply


Forum Jump:


Users browsing this thread:
2 Guest(s)