pdf-icon

Arduino入門

2. デバイス&サンプル

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