Button

Overview

Displays the status of the boot mode switch on the ESP32 MCU leaf on the serial monitor.

Leaf to use

Use the following leaf.

Type Name Q’ty
AP02 ESP32 MCU 1

Source code

Write the following program in the Arduino IDE.

//=====================================================================
//  Button
//
//    (c) 2020 Trillion-Node Study Group
//    Released under the MIT license
//    https://opensource.org/licenses/MIT
//
//      Rev.00 2020/07/02  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

Execution Results

When you press the Boot mode switch, the display on the serial monitor will change from 1 to 0.

Back to previous page


Last modified 15.03.2021