🛠 Bouton MODE et console série sur la Boron

Particle Boron · debutant · Schéma : IMG-particle-boron-debutant-2-boron-bouton-mode-console.svg — Boron vue de dessus avec boutons Reset et MODE, câble USB vers un ordinateur affichant une console série.

Objectives

Interact with the local user and debug: read the state of the onboard MODE button, count presses, and display messages on the USB serial console via Serial.begin / Serial.println. You will also discover system modes controlled by buttons (Reset + MODE), which are useful in all subsequent tutorials.

Hardware

Complete code

// Boron — bouton MODE + console série
const uint16_t BUTTON_PIN = MODE;   // broche du bouton MODE — voir remarque 
uint32_t appuis = 0;
uint32_t dernierAppui = 0;

void setup {
    Serial.begin(9600);
    pinMode(BUTTON_PIN, INPUT_PULLUP);  // bouton câblé vers la masse
    delay(1000);                        // laisse le moniteur se connecter
    Serial.println("Boron prete : appuyez sur MODE");
}

void loop {
    uint32_t maintenant = millis;
    if (digitalRead(BUTTON_PIN) == LOW && maintenant - dernierAppui > 200) {
        dernierAppui = maintenant;      // anti-rebond logiciel 200 ms
        appuis++;
        Serial.printf("Appui n°%lu  uptime=%lus\n", appuis, maintenant / 1000);
    }
    if (maintenant % 10000 < 10) {
        Serial.println("tick");         // battement toutes les ~10 s
    }
    delay(10);
}

Flash the firmware, then open the console: particle serial monitor --follow or the VS Code serial extension (9600 baud).

Expected verification

At startup, the message “Boron prete” is displayed. Each press of the MODE button prints a line with the press number and uptime; a long or repeated press should not produce more than a few lines thanks to debouncing. The “tick” beat confirms that the loop is running. By holding Reset and then pressing MODE, you enter system modes (DFU, listening) — the RGB LED changes color.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials