Arduino Quick Start
APIs and example programs related to button input on Atom EchoS3R.
M5.update()
function in the main loop to read state updates. Also, try to minimize blocking operations, otherwise button 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("BtnA was pressed");
}
}
This program will detect whether the button on the front of the device is pressed and print a message in the serial monitor:
The button part of Atom EchoS3R uses the Button_Class
from the M5Unified
library. For more related APIs, please refer to the following documentation: