scan-16-analogiques.ino
The Mega offers 16 10-bit inputs: this batch read walks them every 500 ms and sends one row to the serial plotter. Unconnected pins float — tie a resistor to GND to stabilize them.
Hardware required
An Arduino Mega 2560 (ATmega2560, 16 MHz, 5 V): 54 digital I/O, 15 PWM, 16 analog inputs, 4 hardware UARTs. Optional: sensors or potentiometers on A0-A15.
Wiring
Each sensor between 5 V/GND and its Axx pin; common grounds.
How it works
A0 + p iterates the 16 ADC multiplexer channels; conversions run back to back, hence the full row in a few milliseconds. In the Arduino IDE, select « Arduino Mega 2560 » and the port, then Upload. PWM on 2-13 and 44-46; UART1=18/19, UART2=16/17, UART3=14/15; SPI on 50-53.
Going further
Extend the idea with a CD74HC4067 multiplexer for 16 more channels.
scan-16-analogiques.ino
// Acquittement des 16 entrees analogiques (A0..A15).
unsigned long precedent = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
if (millis() - precedent >= 500) {
precedent = millis();
for (int p = 0; p < 16; p++) {
Serial.print(analogRead(A0 + p)); // 0..1023
Serial.print(p == 15 ? '\n' : '\t');
}
}
}