A push button is a simple mechanical switch that connects two points in a circuit when pressed.
Normally Open (NO): Most common type — the circuit is open (OFF) when the button is not pressed.
When pressed: The circuit closes, allowing current to flow.
ESP32 board
Push button
10kΩ resistor (for pull-down, optional if using internal pull-up)
Jumper wires
Breadboard
| Button Pin | ESP32 |
|---|---|
| One leg | GND |
| Other leg | GPIO 14 (or any digital pin) |
No resistor needed — we'll use the internal pull-up.
Button not pressed: Pin reads HIGH (connected internally to 3.3V)
Button pressed: Pin reads LOW (connected to GND)
#define BUTTON_PIN 14 // Connect push button to GPIO14
void setup() {
Serial.begin(115200); pinMode(BUTTON_PIN, INPUT_PULLUP); // Use internal pull-up resistor
}
void loop() {
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) {
Serial.println("π Button Pressed");
}else {
Serial.println("β Button Released"); }
delay(200); // debounce delay
}
#define BUTTON_PIN 14#define LED_PIN 2 // Onboard LED (optional external)
void setup() {
Serial.begin(115200); pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) {
digitalWrite(LED_PIN, HIGH); // Turn on LED
} else {
digitalWrite(LED_PIN, LOW); // Turn off LED
}
}USING Button.h LibraryButton library by J-M-L or othersThese libraries are often named just Button.h, and are designed to simplify:
Debouncing
Single press
Long press
Multi-click detection
Button.h Library with ESP32π Note: Since
Button.his a generic name, I’ll assume you're referring to a standard Arduino button library that providesbutton.isPressed()or similar methods. If you meant a different specific library, let me know!
In Arduino IDE
Go to Sketch > Include Library > Manage Libraries
Search for Button
You may see something like:
Button by J-M-L
EasyButton
OneButton (also common and good)
Pick one based on features. Let's continue with the simple "Button.h" by J-M-L version.
Button one side → GND
Button other side → GPIO 14 (or any digital input)
HOW TO OPERATE
As per official documentation Step by step process for pico program run after power on:Save your pyt...
ESP32 Board are so popular? Mainly because of the following featuresLow-costBluetoothWiFiLow PowerDu...
Node MCU ESP8266 Board are so popular? Mainly because of the following features.Its true Arduino Kil...
π§ Basic IntroductionL298N is a dual H-Bridge motor driver IC that allows controlling the direction...
π§ Components Needed:ComponentQuantityESP32 Dev Board1L298N Motor Driver Module1DC Gear Motors (TT o...
The ADXL335 is a small, thin, low-power 3-axis analog accelerometer manufactured by Analog Devices....
π§ What is an Ultrasonic Sensor?An ultrasonic sensor is a device that uses sound waves to detect how...
π What is the DHT11 Sensor?The DHT11 is a basic, low-cost digital temperature and humidity sensor....
π₯ FIRE BOT β Bluetooth Controlled Fire Extinguisher RobotWelcome to the FIRE BOT project! This robo...
BMP180 Sensor: Digital Barometric Pressure SensorThe BMP180 is a digital barometric pressure sensor...
π§ 1. Hardware Overview: 1.8" TFT DisplayMost 1.8" TFT modules are based on the ST7735 driver and co...
The SSD1306 is a popular controller used in OLED (Organic Light Emitting Diode) displays, most commo...
A servo motor is a type of motor designed for precise control of angular position, making it ideal f...
The Gravity Voice Recognition Module is a user-friendly module developed by DFRobot that allows micr...
The APDS-9960 is an advanced, compact sensor from Broadcom (formerly Avago Technologies) that offers...
π What is the 28BYJ-48 Stepper Motor?The 28BYJ-48 is a 5V unipolar stepper motor with a built-in re...
How Soil Moisture Sensor Works and Interface it with Esp32Β When you hear the term βsmart garden,β on...
π§ What is an Analog Joystick?An analog joystick typically has:2 potentiometers (one for X-axis, one...
π‘ What is the NEO-8M GPS Module?The NEO-8M is a high-precision GNSS GPS receiver by u-blox, capable...
π§ What is a NeoPixel?NeoPixel is Adafruitβs name for individually addressable RGB LEDs using the WS...
π§ What is a PIR Sensor?PIR = Passive Infrared SensorA PIR sensor detects motion by measuring change...
β What is AI Thinker GP-02?The AI Thinker GP-02 is a GNSS (GPS) module, designed to work with satel...
π‘ What is SIM900?The SIM900 is a GSM/GPRS module from SIMCom. It allows microcontrollers like ESP32...
π€ What is a Tilt Sensor?A tilt sensor (also called a ball switch or mercury switch) is a digital sw...
π¨ What is the TCS34725?The TCS34725 is a color sensor made by AMS (now part of Renesas).It detects...
π What is an I2C LCD?An I2C LCD is a Liquid Crystal Display that uses the I2C communication protoco...
π§ What is MPU6050?The MPU6050 is a 6-axis motion tracking device made by InvenSense. It combines:β ...
π‘οΈ What is DS18B20?The DS18B20 is a digital temperature sensor from Maxim Integrated (now Analog Dev...
β° What is DS1307 RTC?The DS1307Β is a real-time clock IC by Maxim Integrated that keeps track of:Sec...
π΅ What is DFPlayer Mini?The DFPlayer Mini is a tiny, standalone MP3 audio player module. It can pla...
π‘ What is an IR Receiver?An IR (Infrared) Receiver module receives signals from an IR remote contro...
π What is a Rotary Encoder?A rotary encoder is an electro-mechanical sensor that converts the angul...
π What is the Dot Matrix Display with MAX7219?A Dot Matrix Display is an arrangement of LEDs in a g...
π What is ESP-NOW?ESP-NOW is a wireless communication protocol developed by Espressif, allowing ESP...
π€ ESP32 Joystick Controlled Robot Using ESP-NOW Protocol & L298N Motor DriverWireless bot control w...
β€οΈ Heart Rate & SpOβ Sensor (MAX30100/MAX30102)π¬ Pulse Sensor | SpOβ Monitor | Wearable Health Tech...