mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-30 20:40:59 +02:00
* Added ADC API doc + simple example * Added attenuation input voltage range + conf.py added tabs extension * Update requirements.txt * Update adc.rst
20 lines
553 B
C++
20 lines
553 B
C++
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
|
|
}
|