
Arduino Quick Start
Arduino Nesso N1 button input-related API and example program.
M5.update() function in the main loop to read status updates and minimize blocking as much as possible, otherwise button state changes may not be captured in time.#include "M5Unified.h"
void setup()
{
auto cfg = M5.config();
cfg.serial_baudrate = 115200;
M5.begin(cfg);
}
void loop()
{
M5.update();
if (M5.BtnA.wasPressed()) {
Serial.println("A Btn Pressed");
}
if (M5.BtnA.wasReleased()) {
Serial.println("A Btn Released");
}
if (M5.BtnB.wasPressed()) {
Serial.println("B Btn Pressed");
}
if (M5.BtnB.wasReleased()) {
Serial.println("B Btn Released");
}
}
The button driver of Arduino Nesso N1 uses the Button_Class in the M5Unified library. For more button-related APIs, please refer to the following document: