Newer
Older
OurSketch / SampleSrc / button01.ino
@motoki miura motoki miura on 10 May 2022 690 bytes SampleSource
#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);
}