Skip to content

This project shows how to control an LED using a **push button** connected to an **ESP8266** microcontroller. It’s a simple digital input/output example using **MicroPython** in the **Thonny IDE**.

Notifications You must be signed in to change notification settings

asathiskumar98-byte/ESP8266-Button-Controlled-LED-using-MicroPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔘 ESP8266 Button Controlled LED using MicroPython

This project shows how to control an LED using a push button connected to an ESP8266 microcontroller.
It’s a simple digital input/output example using MicroPython in the Thonny IDE.


🧠 Project Overview

Component Description
Board ESP8266
IDE Thonny IDE
Language MicroPython
USB Driver Silicon Labs CP210x USB to UART Bridge
LED Pin GPIO2
Push Button Pin GPIO0

⚙️ Requirements

  • ESP8266 (NodeMCU or compatible)
  • 1 LED + 220Ω resistor
  • 1 Push Button
  • Micro USB cable
  • Thonny IDE
  • CP210x USB Driver
  • MicroPython firmware flashed on ESP8266

🧩 Circuit Connections

ESP8266 Pin Component Description
GPIO2 LED Active Low
GPIO0 Push Button Input (active low)
GND LED (-) and Button GND Common Ground

💡 Tip: Use a pull-up resistor (or internal pull-up) on GPIO0 if your button behaves erratically.


💻 Code

import machine # GPIO2 = LED # GPIO0 = Pushbutton led = machine.Pin(2, machine.Pin.OUT) button = machine.Pin(0, machine.Pin.IN) while True: if button.value() == 0: # Button pressed led.value(0) # LED ON else: # Button released led.value(1) # LED OFF

About

This project shows how to control an LED using a **push button** connected to an **ESP8266** microcontroller. It’s a simple digital input/output example using **MicroPython** in the **Thonny IDE**.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages