Arduino Quick Start
APIs and example programs related to Dial button input.
M5Dial.update()
function in the main loop to read status updates. Try to minimize blocking operations; otherwise, button state changes may not be detected in time.#include "M5Dial.h"
void setup() {
auto cfg = M5.config();
M5Dial.begin(cfg, false, false); // encoder, RFID
Serial.begin(115200);
}
void loop() {
M5Dial.update();
if (M5Dial.BtnA.wasPressed()) {
Serial.println("Button A Pressed");
}
if (M5Dial.BtnA.wasReleased()) {
Serial.println("Button A Released");
}
}
The M5Dial
library is built on top of the M5Unified
library. The button driver uses the Button_Class
provided by M5Unified
. For more related APIs, please refer to the following document: