Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[arduino code examples for A8v3]-03 Read analog input ports value
#1
Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* Description:
* This Arduino program reads analog values from four analog input pins (A1, A2)
* and prints the values to the Serial Monitor. The analog inputs are defined with specific
* GPIO pins and the program reads the voltage levels from these pins every 2 seconds.
*
* Pin Definitions:
* - A1: GPIO 7
* - A2: GPIO 6

*/

#define ANALOG_A1   7   // Define GPIO pin for analog input A1
#define ANALOG_A2   6   // Define GPIO pin for analog input A2


void setup()
{
    Serial.begin(115200); // Initialize serial communication at 115200 baud rate
    delay(500); // Short delay to allow serial communication to start

    pinMode(ANALOG_A1, INPUT); // Set GPIO 5 as an input for analog signal A1
    pinMode(ANALOG_A2, INPUT); // Set GPIO 7 as an input for analog signal A2

}

void loop()
{
    // Read and print analog values from the defined pins
    Serial.print("A1=");
    Serial.println(analogRead(ANALOG_A1)); // Read and print the value from A1
    Serial.print("A2=");
    Serial.println(analogRead(ANALOG_A2)); // Read and print the value from A2   
    delay(2000); // Wait for 2 seconds before the next reading
}
arduino ino file download:

.zip   3-analog-input.zip (Size: 698 bytes / Downloads: 300)
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.59 KB / Downloads: 291)
Reply


Messages In This Thread
[arduino code examples for A8v3]-03 Read analog input ports value - by admin - 04-20-2025, 06:34 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)