Arduino 上手教程
Fire 按键输入相关 API 与案例程序。
M5.update()
函数用于读取状态更新,且尽可能减少阻塞,否则可能无法及时获取按键变化。#include "M5Unified.h"
void setup() {
M5.begin();
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");
}
}
该程序将检测三个按钮是否被按下,并在串口监视器打印消息:
Fire 按键部分使用了M5Unified
库中的Button_Class
,更多相关的 API 可以参考下方文档: