Arduino Quick Start
M5Fire button input related APIs and example program.
M5.update()
function in the main loop to read status update and minimize blocking, otherwise you may not to be able to retrieve the status of key changes in time.#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"); }}
For actual implementation results, download the example program, press the buttons, and open the serial monitor to see the output.
The button part of Fire uses the Button_Class
in the M5Unified library. For more APIs related to buttons, you can refer to the document below: