Analog Read Multiple example sketch Reads all six analog pins together with analogReadMultiple() and streams them, in millivolts, to the Serial Plotter 20 times a second. A3-A5 are read in one scan of the external ADC, A0-A2 back to back on the RP2040 ADC.
- Output
- Tools → Serial Plotter at 115200 baud, one line per reading:
A0:1650,A1:3,A2:0,A3:1024,A4:0,A5:0
const pin_size_t PINS[] = {A0, A1, A2, A3, A4, A5};
const char* const NAMES[] = {"A0", "A1", "A2", "A3", "A4", "A5"};
const uint8_t COUNT = 6;
}
uint16_t values[COUNT];
for (uint8_t i = 0; i < COUNT; i++) {
Serial.print(i + 1 < COUNT ?
"," :
"\n");
}
}
SerialUSBClass Serial
USB serial port, the one the Serial Monitor uses.
void analogReadResolution(int bits)
Sets the number of bits analogRead() returns, for every analog pin.
uint32_t analogFullScaleMillivolts(pin_size_t pin)
Voltage that reads as full scale on an analog pin.
bool analogReadMultiple(const pin_size_t *pins, uint8_t count, uint16_t *results)
Reads several analog pins as close together in time as possible.
void loop(void)
Written by the sketch: runs over and over after setup(), on core 0.
void setup(void)
Written by the sketch: runs once after reset, on core 0.
void delay(unsigned long)
Waits a number of milliseconds.
uint8_t pin_size_t
Type for Arduino pin numbers (uint8_t).
Definition Common.h:112