
Arduino Quick Start
APIs and example programs related to AtomS3R button input.
M5.update() function in the main loop to refresh the status, and minimize blocking operations as much as possible. Otherwise, button state changes may not be detected in time.#include "M5Unified.h"
void setup() {
M5.begin();
Serial.begin(115200);
}
void loop() {
M5.update();
if (M5.BtnA.wasPressed()) {
Serial.println("Pressed");
}
if (M5.BtnA.wasReleased()) {
Serial.println("Released");
}
}After uploading the above program to AtomS3R, open the serial monitor. When the button (screen) is pressed, it will output "Pressed", and when the button (screen) is released, it will output "Released".
The AtomS3R button feature uses Button_Class from the M5Unified library. For more button-related APIs, refer to the documentation below: