pdf-icon

Arduino Guide

Button

CoreInk Button input related APIs and case programs.

Note:
Include M5.update() function in the main loop to read status update and minimize blocking, otherwise you may not be able to retrieve the status of key changes in time.

Example

#include "M5Unified.h"

void setup()
{
    auto cfg = M5.config();
    M5.begin(cfg);
    Serial.begin(115200);
}

void loop()
{
    M5.update();
    if (M5.BtnA.wasPressed()) {
        Serial.println("BtnA Pressed");
    }
    if (M5.BtnB.wasPressed()) {
        Serial.println("BtnB Pressed");
    }
    if (M5.BtnC.wasPressed()) {
        Serial.println("BtnC Pressed");
    }
    if (M5.BtnPWR.wasPressed()) {
        Serial.println("BtnPWR Pressed");
    }
    if (M5.BtnEXT.wasPressed()) {
        Serial.println("BtnEXT Pressed");
    }
}

API

The button part of CoreInk uses the Button_Class in the M5Unified library. For more APIs related to buttons, you can refer to the document below:

On This Page