コンテンツにスキップ
ショップ

ボタン入力

ESP32 MCUリーフに搭載されたBoot mode スイッチの状態をシリアルモニタに表示させます。

以下のリーフを使用します

TypeNameQ’ty
AP02ESP32 MCU1

Arduino IDEで下記のプログラムを書きましょう。

//=====================================================================
// Button
//
// (c) 2021 LEAFONY SYSTEMS Co., Ltd
// Released under the MIT license
// https://opensource.org/licenses/MIT
//
// Rev.00 2021/04/01 First release
//=====================================================================
int pushButton = 0;
void setup() {
Serial.begin(115200);
pinMode(pushButton, INPUT);
}
void loop() {
int buttonState = digitalRead(pushButton);
Serial.println(buttonState);
delay(1000);
}

ESP32_Button.ino

Boot mode スイッチを押すと、シリアルモニタの表示が、1から0に変わります。