arduino-esp32-custom-lwip-p.../libraries/ESP32/examples/AnalogRead/AnalogRead.ino

20 lines
553 B
Arduino
Raw Permalink Normal View History

2023-02-25 16:13:53 +01:00
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
//set the resolution to 12 bits (0-4096)
analogReadResolution(12);
}
void loop() {
// read the analog / millivolts value for pin 2:
int analogValue = analogRead(2);
int analogVolts = analogReadMilliVolts(2);
// print out the values you read:
Serial.printf("ADC analog value = %d\n",analogValue);
Serial.printf("ADC millivolts value = %d\n",analogVolts);
delay(100); // delay in between reads for clear read from serial
}