pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

NanoC6 Button

NanoC6 Button related APIs and example program.

Example Program

Compilation Requirements

  • M5Stack Board Manager version >= 3.2.5
  • Board option = M5NanoC6
  • M5NanoC6 Library version = 1.0.0
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <M5NanoC6.h>

void setup() {
    NanoC6.begin();
}

void loop() {
    NanoC6.update();
    if (NanoC6.BtnA.wasPressed()) {
        Serial.println("Button A was pressed");
    }
    if (NanoC6.BtnA.wasHold()) {
        Serial.println("Button A was hold");
    }
    if (NanoC6.BtnA.wasReleased()) {
        Serial.println("Button A was released");
    }
}

This program detects the status of the front button on the NanoC6 and prints button events in the serial monitor:

API

The button section of NanoC6 refers to the Button_Class in the M5Unified library. For more button-related APIs, please refer to the documentation below:

On This Page