🛠 Faire clignoter la LED utilisateur
Objectives
Discover the MKR WiFi 1010 board by blinking the user LED, and understand which of the three LEDs you are controlling: the user LED is connected to pin D6 (LED_BUILTIN = 6), the ON LED is simply tied to the 5 V rail (not controllable), and a directional RGB LED is onboard. This is the starting point of the entire series.
Hardware
- 1 × Arduino MKR WiFi 1010 board
- 1 × micro-USB cable (data, not just charging)
- Optional: LED + 330 Ω resistor on a digital pin — reminder: 3.3 V logic and 7 mA max per pin, never use an LED without a resistor
Complete code
// Clignotement de la LED utilisateur (D6) de la MKR WiFi 1010.
const uint8_t LED = LED_BUILTIN; // = 6 sur cette carte
void setup {
pinMode(LED, OUTPUT);
Serial.begin(115200);
}
void loop {
digitalWrite(LED, HIGH);
Serial.println("LED ON");
delay(200);
digitalWrite(LED, LOW);
delay(800);
}
Expected verification
In the Arduino IDE, select the "Arduino MKR WiFi 1010" board and the corresponding port, then upload. The user LED blinks in a short/long rhythm (200 ms ON, 800 ms OFF) and Serial.println scrolls at 115200 bauds in the serial monitor. The first upload may trigger a "1200 bauds" (touch) reset specific to the SAMD bootloader: this is normal.
Common errors
- You are using
LED_BUILTINfrom another board (13 on Uno): here it is D6, but the constant is already correct in the SAMD core, do not replace it with 13. - The serial port disappears during upload: reconnect or double-reset to put the bootloader back into boot mode.
- You are looking for the ON LED: it will never blink, it lights up as soon as 5 V is present (so it remains off on battery, by design).
- An external LED connected without a resistor quickly exceeds 7 mA per pin and can damage the SAMD21.
Other tutorials for this board
Code examples for this board
scan-wifi.inoArduinoconnexion-wpa2.inoArduinohttp-get.inoArduinoserveur-web-led.inoArduinohorloge-ntp.inoArduinoudp-diffusion.inoArduino