Newer
Older
m5stickcplus / src / button01.ino
@Motoki Miura Motoki Miura on 4 Mar 2021 690 bytes ir
#include <M5StickCPlus.h>

void setup() {
  M5.begin();
  M5.Lcd.setRotation(3);
}

void loop() {
  M5.update(); // 各ボタンの状態を(読み取って)更新する:ボタンを判定するときは必須。

  if (M5.BtnA.wasReleasefor(1000) ) {
    Serial.println("[A] was Pressed longer than 1s");
  } else if (M5.BtnA.wasReleased()) {
    Serial.println("[A] was Pressed");
  } else if (M5.BtnB.wasReleasefor(1000) ) {
    Serial.println("[B] was Pressed longer than 1s");
  } else if (M5.BtnB.wasReleased()) {
    Serial.println("[B] was Pressed");
  } else if (M5.Axp.GetBtnPress() == 2) {
    Serial.println("[Power] was Pressed");
  }
  delay(10);
}