Control the lighting of LED by push button with ESP32

Purpose of this tutorial:

In this tutorial we will control the lighting of an LED via a push button:

1- When the button is pressed, the LED lights up

2- When the button is released, the LED goes out.

Necessary components

  • ESP32
  • Red LED
  • pushbutton
  • des fils de connexion
  • plaque d’essai


We connect pin D23 of the ESP32 board to the anode (+ terminal) of the LED and the GND of the ESP32 board to the cathode (- terminal) of the LED.

We connect the first pin of the push button to the GND pin of the ESP32 board and the second pin of the push button to the D21 pin of the ESP32 board.

Micropython program

Here is the program that controls the ignition of an LED connected to pin D23 of the ESP32 board.

1 commentaire

Finley 21-08-2222

Are you writing the articles in your website yourself or you outsource them? I am a blogger and having difficulty with content. Other bloggers told me I should use an AI content writer, they are actually pretty good. Here is a sample article some bloggers shared with me.

Leave a comment

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Scroll to Top