pdf-icon

Arduino 上手教程

Atom System 系统函数

begin

功能说明:

清空串口缓冲区,设置串口波特率为 115200,初始化I2C,初始化LED矩阵

函数原型:

void begin(bool SerialEnable, bool I2CEnable, bool DisplayEnable);

案例程序:

cpp
1 2 3 4
#include "M5Atom.h"
void setup(){
M5.begin(true, true, true); //清空串口缓冲区,设置串口波特率为 115200,初始化I2C,初始化LED矩阵
}

update

功能说明:

读取按键的状态。

函数原型:

void update();

案例程序:

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "M5Atom.h"
#include <M5Atom.h>
void setup() {
M5.begin();
}
void loop() {
M5.update(); //需添加M5.update()才能读取到按键的状态,细节请见System
if (M5.Btn.isPressed()) { //如果按键按下
Serial.println("Button is pressed.");
}
delay(20);
}
On This Page