clignotante.ino

Arduino Mega ADK (Rev3) · File : clignotante.ino · Language : Arduino · Use case : Faire clignoter la LED intégrée pour vérifier la carte

The go-to sanity check: the LED on pin 13 blinks at 1 Hz. millis() replaces delay() to keep the loop free. If nothing blinks, suspect the upload or the board selection.

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). No external component: the onboard user LED is enough.

Wiring

Nothing to wire, the LED sits on pin 13 behind a current-limiting resistor.

How it works

Each loop pass compares millis() with the last change; after 500 ms the pin state flips. 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

Vary PERIODE, or add an external LED with a 330 Ω resistor on another pin. La LED 13 sert aussi de témoin de liaison ADK.

clignotante.ino

// Clignotement de la LED integree (broche 13, alias LED_BUILTIN).
const long PERIODE = 500; // ms entre deux changements d'etat

bool etat = false;
unsigned long precedent = 0;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  Serial.println(F("Clignotement demarre"));
}

void loop() {
  unsigned long t = millis();
  if (t - precedent >= PERIODE) {
    precedent = t;
    etat = !etat;
    digitalWrite(LED_BUILTIN, etat ? HIGH : LOW);
    Serial.println(etat ? F("ON") : F("OFF"));
  }
}

← Back to the board