Skip to content

boydjawun/arduino-esp32-onoff-button-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

🚨 Arduino ESP32 On/Off Button Contoller

Demo

🗨️ Description

This project is perfect for anyone just starting with microcontrollers, Arduino, or the HackerBoxes ecosystem. All materials used in this project come from HackerBoxes's Core Workshop. It's low-cost, instant-gratification fun, and shows how simple components can create something interactive and surprising.

🔨Hardware + 💻Software + 📝Module Used

  • ESP-WROOM-32 Development Board (ESP32 microcontroller)
  • USB-A to USB-C Cable 1m
  • 10KΩ pull-up resistor
  • Solderless 830-point breadboard
  • 5mm Blue LED Light
  • Tactile momentary push button
  • 3 Female-Male Jumper wires
  • Developed in Arduino IDE
  • Based on the classic Blink example (File > Examples > 01.Basics > Blink)

🌻 What I Learned From This Simple Project

Breadboarding basics — How rows/columns are connected internally, power/ground rails, and avoiding short circuits.

Microcontroller GPIO — Digital vs. analog/PWM output, pin configuration in Arduino, uploading sketches via USB.

Circuits fundamentals — Ohm's Law in action! Resistance affects current → affects LED brightness. Graphite from a pencil is a real (and surprisingly useful) resistive material.

Prototyping mindset — Using everyday household items (pencils!) to experiment quickly without buying specialized components.

Debugging — Why an LED might not light, flicker, or behave unexpectedly (loose connections, wrong pin, resistance too high/low).

Joy of hacking — Taking a standard Blink sketch and turning it into something interactive and physical in minutes is incredibly motivating for beginners like me.

🤔 What is an ESP32?

The ESP32 used in this project is the ESP-WROOM-32 Development Board, a popular module based on the Espressif ESP32 microcontroller SoC (System-on-Chip).

Light On, Pencil Lifted

It is a powerful, low-cost, dual-core 32-bit processor (typically running at up to 240 MHz) that integrates built-in Wi-Fi (2.4 GHz) and Bluetooth (Classic + BLE) connectivity, along with ample RAM (around 512 KB) and flash memory. This makes it ideal for wireless-enabled projects, as it handles networking and processing without needing extra modules. In the workshop, it's used for hands-on experiments like configuring it with the Arduino IDE, running I2S audio examples, interfacing with sensors/components, and exploring wireless features.

In ESP32-powered projects, it generally serves as the main brain: running code (via Arduino, MicroPython, ESP-IDF, etc.), processing inputs/outputs via its many GPIO pins, managing communication protocols (I2C, SPI, UART, etc.), handling wireless data transfer, and enabling low-power or real-time operations.

Here are 3 common things an ESP32 can be used for:

IoT devices and smart home projects — Such as Wi-Fi-connected sensors (temperature, motion, etc.) that send data to the cloud, control appliances remotely, or integrate with home automation systems like Home Assistant.

Wireless audio streaming or players — Leveraging its Bluetooth and I2S capabilities to build speakers, internet radios, or audio receivers that stream music from phones or online sources.

Security/penetration testing tools — Like Wi-Fi/Bluetooth scanners, packet sniffers, or wardriving setups (e.g., projects like ESP32 Marauder for network reconnaissance and testing).

🤔 What is ArduinoIDE?

Arduino IDE (short for Arduino Integrated Development Environment) is a free, open-source software application designed primarily for programming Arduino microcontroller boards (and compatible ones like many ESP32 variants). It provides a simple, beginner-friendly interface that includes a text editor for writing code (called "sketches"), tools to compile/verify the code, and a one-click way to upload it to the connected board via USB. It supports the Arduino programming language (a simplified version of C/C++) and works on Windows, macOS, and Linux. The current major version is Arduino IDE 2.x, which offers modern features like autocompletion, better debugging, and a more responsive UI compared to the classic 1.x version.

Here are 3 common things the Arduino IDE is used for:

Writing and uploading code to microcontroller boards — Its primary purpose: create sketches to control hardware like LEDs, sensors, motors, or displays, then compile and flash them directly to an Arduino/ESP32 board. Prototyping electronics and IoT projects — Hobbyists, students, and makers use it to quickly test ideas, such as building robots, home automation devices, environmental monitors (e.g., temperature/humidity sensors with data logging), or interactive art installations.

Learning programming and embedded systems — It's widely used in education and beginner tutorials due to its simplicity, extensive built-in examples (like Blink, Analog Read, or Serial communication), and large community libraries for adding features (e.g., Wi-Fi, Bluetooth, displays, or audio)

🚨 Arduino ESP32 On/Off Button Contoller

Before starting, install Arduino IDE

Connecting the ESP32, Blue LED light, and Breadboard

  • Use the Jumper wire to connect from pin 2 of the ESP32 to the breadboad with the female-male jumper wire. I perferred using seprate sides of the breadboard as appearent in the photos.
  • On the same row that pin 2 is connected to the breadboard from ESP32, connect another female-male jumper wire from that row to the long leg of the LED light
  • Place the other leg of the led light in the other side of the breadbard

First Steps

Step 1

Connecting Resistor and Ground(GND) Wires

  • Use the Resistor to connect from the shorter end of the LED light's row to another row's rail
  • Connect a Female-Male Jumper Wire from the same row as the resistor, to the GND(Ground) pin on the ESP32
  • Attach the ESP32 Dev Board to a computer using a USB-C cable

Second Step

Step 2

Adding ESP32 Board to Arduino and Uploading Blink Code

  • In File > Preferences, add the standard Espressif github repo in the "Additional Boards Manager URLs" field: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json then click "OK"
  • Then search for "ESP32" in Tools > Board > Boards Manager, find the package by Espressif Systems
  • Select that board package and hit install
  • From the top menu, select Tools > Board > esp32 > ESP32 Dev Module
  • Select Tools > Port (COM port that appears when the ESP32 is connected and turned on)
  • Open the sketch File > Examples > 01.Basics > Blink
  • Add the line #define LED_BUILTIN 2 at the top of the sketch
  • Compile an upload the sketch to the Dev Board

Results

If everything is in order, the sketch will cause the blue LED that is connected to pin 2 to begin blinking, when the button is pressed and held, the light will stop. You can view the project in action on Simple Electronics Tutorials's YouTube Channel.

Light off, pencil pressing the button

Light off, pencil pressing the button

Light on, pencil lifted

Light on, pencil lifted

About

LED on/off button using ArduinoIDE and an ESP-WROOM-32 Development Board

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages