scan-16-analogiques.ino

Arduino Mega ADK (Rev3) · File : scan-16-analogiques.ino · Language : Arduino · Use case : Acquitter les 16 entrées analogiques en un seul tour de boucle

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 ADK Rev3 (ATmega2560 + MAX3421E USB host chip with a Type-A port; digital pin 7 is reserved for the MAX3421E reset). 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. Select « Arduino Mega ADK » in the IDE. For USB host/ADK work, install the USB Host Shield 2.0 library; do not use D7. The USB-A port powers the accessory at 5 V.

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');
    }
  }
}

← Back to the board