This project is an ESP32-based Bluetooth Serial LED Controller designed to allow users to control LEDs via Bluetooth using custom commands. The system also includes functionality to read button inputs and respond accordingly, making it versatile for various applications.
- Bluetooth Connectivity: Communicate with the ESP32 through Bluetooth for wireless control.
- LED Control: Manage LED states (ON/OFF) and toggle modes based on received commands.
- Button Integration: Read button states for additional physical control.
- Custom Commands: Supports commands such as
POWER
,ALTERNATE
,+
,-
, andTIMER
for advanced LED control. - Timer Functionality: Set a countdown timer to automatically turn off LEDs after a specified duration.
- Real-Time Status Update: Uses USB Serial and Bluetooth Serial for device communication and status monitoring.
- Microcontroller: ESP32
- LEDs: At least one LED (connected to GPIO 2 by default).
- Push Buttons: Connected to GPIOs 0, 4, 17, and 16 (modifiable in code).
- Power Supply: 5V for the ESP32 module.
-
Hardware:
- ESP32 microcontroller
- LEDs and resistors
- Push buttons (optional)
-
Software:
- Arduino IDE with ESP32 board support installed.
-
Clone the Repository
git clone https://github.com/TheLonelyOtaku315/ESP32-LED-Controller.git
Or download the project files and extract them.
-
Open the Project
- Open
Bluetooth_Serial_LED_Controller.ino
in the Arduino IDE.
- Open
-
Configure the Code
- Modify the
pins
andcommands
vectors as needed to suit your setup.
- Modify the
-
Upload the Code
- Connect the ESP32 to your computer via USB.
- Select the correct COM port and board in the Arduino IDE.
- Click on
Upload
to flash the program to the ESP32.
-
Test the Setup
- Pair your ESP32 with your device using Bluetooth (
ESP32LEDControl
as default name). - Use a Bluetooth terminal app (e.g., Serial Bluetooth Terminal) to send commands.
- Pair your ESP32 with your device using Bluetooth (
-
Pair with the ESP32:
- Search for the device named
ESP32LEDControl
and pair with it.
- Search for the device named
-
Send Commands:
- Use a Bluetooth terminal app to send predefined commands:
POWER
: Toggle all LEDs ON/OFF.ALTERNATE
: Switch LEDs in an alternating pattern.+
: Increase brightness (if PWM is implemented).-
: Decrease brightness (if PWM is implemented).TIMER
: Set a countdown timer in seconds. The LEDs will turn off automatically when the timer ends.
- Use a Bluetooth terminal app to send predefined commands:
-
Monitor via Serial:
- Open the Serial Monitor in the Arduino IDE to view logs and debug messages.
- Setup: Initializes Bluetooth, serial communication, and pin configurations.
- Loop:
- Checks Bluetooth connection status.
- Monitors button states and updates the corresponding LED actions.
- Processes received Bluetooth commands.
- Manages the timer functionality to power off LEDs after the specified duration.
- Update the
pins
array to define GPIOs connected to buttons. - Add or modify commands in the
commands
array for additional functionality. - Expand LED control logic as needed.
- Bluetooth Not Connecting: Ensure the ESP32 is powered and in range. Try unpairing and pairing again.
- Commands Not Working: Verify the correct commands are sent through the terminal app.
- LEDs Not Responding: Check wiring and ensure the LEDs are functional.
The source code and related files for this project are available on GitHub: ESP32 LED Controller
This project is open-source and available under the MIT License. Feel free to use, modify, and distribute the code.
Special thanks to the Arduino and ESP32 communities for providing extensive resources and support.