Button

Use this page with AI

Explore with your favorite AI

Gemini & other AI

Copy this page’s context into your AI to explore how it works and what you can build.

Open Gemini

Copy the prompt, then paste it into Gemini’s message box.

View prompt

Table of contents

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.

TypeNameQ’ty
AP02ESP32 MCU1

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.

Leaf photo
Search documentation, sample apps, and Q&A