◆Smart Home Ideas Journal

Esp32 S3 RGB LED Arduino Example

By

Embarking on your journey to illuminate your ESP32 S3 board with a vibrant RGB LED? You're in the right place. Today, we'll explore a simple yet engaging Arduino example to control an RGB LED using your ESP32 S3. So, let's dive into this fascinating realm of IoT and colors!

Before we ignite the RGB LED, let's briefly understand why ESP32 S3 is an excellent choice for such projects. The ESP32 S3, an upgraded version of the ESP32, offers improved performance, more GPIO pins (up to 45), and increased flash memory. Needless to say, it's a delight for electronics enthusiasts and hobbyists alike!

Setting up the ESP32 S3 and RGB LED

For this project, you'll need the following components: an ESP32 S3 board, an RGB LED (common cathode), 3x resistors (220 ohm - 330 ohm each), and jumper wires. Connect your RGB LED to digital pins 16, 17, and 18 of your ESP32 S3. Ensure you're using appropriate resistors to limit current flow.

a cell phone sitting on top of a table next to an electronic device and wires
a cell phone sitting on top of a table next to an electronic device and wires
💡 ESP32 Web Server – Control an LED from Your Browser!
💡 ESP32 Web Server – Control an LED from Your Browser!
ESP32-S3 YOUTH #2 - How to Run RGB & Buzzer?
ESP32-S3 YOUTH #2 - How to Run RGB & Buzzer?

Now, let's discuss the firmware. You'll need the Arduino IDE (if you don't have it, download it from the official website), and the ESP32 board management package. Follow these simple steps to install the ESP32 board package: open the Arduino IDE, navigate to 'File' > 'Preferences', paste 'https://dl.espressif.com/dl/package_esp32_index.json' into the 'Additional Boards Manager URLs' field, and then install 'esp32' from the Board Manager.

Writing and Uploading the Arduino Sketch

Open the Arduino IDE, create a new sketch, and paste the following code. This basic sketch will cycle through various colors, demonstrating RGB LED control.

WLED ON XIAO ESP32
WLED ON XIAO ESP32
10 ESP32 Skills Every Maker Should Learn
10 ESP32 Skills Every Maker Should Learn
ESP32 PWM with Arduino IDE (Analog Output) | Random Nerd Tutorials
ESP32 PWM with Arduino IDE (Analog Output) | Random Nerd Tutorials
```cpp #define LED_R 16 #define LED_G 17 #define LED_B 18 void setup() { pinMode(LED_R, OUTPUT); pinMode(LED_G, OUTPUT); pinMode(LED_B, OUTPUT); } void loop() { // Red analogWrite(LED_R, 255); analogWrite(LED_G, 0); analogWrite(LED_B, 0); delay(1000); // Green analogWrite(LED_R, 0); analogWrite(LED_G, 255); analogWrite(LED_B, 0); delay(1000); // Blue analogWrite(LED_R, 0); analogWrite(LED_G, 0); analogWrite(LED_B, 255); delay(1000); } ```

Upload this sketch to your ESP32 S3. To do this, first, select 'ESP32 Arduino' from the board selection dropdown ('Tools' > 'Board'), then select 'ESP32 S3' if it's not already selected. Click the 'Upload' button (right arrow icon).

displaying Colors

Upon successful upload, your RGB LED should start displaying colors - one at a time, with a 1-second interval. Red appears first, followed by green, blue, and the sequence repeats.

Customize the colors and intervals in the sketch to create stunning visual effects. For instance, to create purple, use 'analogWrite(LED_R, 127); analogWrite(LED_B, 127);'. To increase the interval between colors to 2 seconds, change the delay to 2000.

How to Easily Control Addressable LEDs with an ESP32 or ESP8266 | WLED Project
How to Easily Control Addressable LEDs with an ESP32 or ESP8266 | WLED Project
How to Power the ESP32 Correctly ⚡
How to Power the ESP32 Correctly ⚡
ESP32 - LED Matrix | ESP32 Tutorial
ESP32 - LED Matrix | ESP32 Tutorial
ESP32 RGB LED Controller Web Server - Remote Color Picker
ESP32 RGB LED Controller Web Server - Remote Color Picker
How to send SMS using ESP32
How to send SMS using ESP32
ESP32 Touch Controlled LED Using Arduino IDE
ESP32 Touch Controlled LED Using Arduino IDE

Exploring Further with RGB LED

Mastered the basics? It's time to delve deeper. Create animations, use color palettes, or even control the LED over the internet using MQTT or Wi-Fi. The possibilities are endless!

To create animations, you'll need to understand color theory and perhaps use libraries like 'FastLED'. Controlling the LED over the internet requires setting up a web server or using a cloud service like IFTTT or Blynk. All these would enhance your learning and skill set.

Color Theory for LEDs

Understanding color theory is crucial for creating visually appealing LED projects. The primary colors are red, green, and blue (RGB). Combining these colors in various proportions creates secondary colors (cyan, magenta, yellow) and other hues. Explore color theory further to create stunning color combinations!

DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
DAY 5 — ESP32 Explained | Wi-Fi & Bluetooth Microcontroller Notes
HUB75 RGB LED matrix library utilizing ESP32 DMA Engine
HUB75 RGB LED matrix library utilizing ESP32 DMA Engine
ESP32 GPIO with ESP-IDF with LED Blinking example
ESP32 GPIO with ESP-IDF with LED Blinking example
My first ESP32 project: Bluetooth Low Energy RGB LED Controller
My first ESP32 project: Bluetooth Low Energy RGB LED Controller
ESP32 microcontroller with two circular 240*240 pixel displays (GCA901)
ESP32 microcontroller with two circular 240*240 pixel displays (GCA901)
Better Debugging for Arduino IDE: SerialDebug Library | Random Nerd Tutorials
Better Debugging for Arduino IDE: SerialDebug Library | Random Nerd Tutorials
ESP32 Pinout Guide: GPIO, Buttons & Ports Explained
ESP32 Pinout Guide: GPIO, Buttons & Ports Explained
5 Must-Try ESP32 Projects for Beginners (2025 Edition)
5 Must-Try ESP32 Projects for Beginners (2025 Edition)
ESP32 Simulator - LED chaser project 🎉😍-2022
ESP32 Simulator - LED chaser project 🎉😍-2022
three different types of electronic devices connected to each other, with the words display below them
three different types of electronic devices connected to each other, with the words display below them
Come Collegare Strisce LED ANALOGICHE RGB con ESP32 e WLED – Guida Completa
Come Collegare Strisce LED ANALOGICHE RGB con ESP32 e WLED – Guida Completa
ESP32 Explained: The Powerful IoT Board
ESP32 Explained: The Powerful IoT Board
How to Make Led Brighter Arduino
How to Make Led Brighter Arduino

To implement color theory in your sketch, replace the individual color lines (e.g., '// Red') with lines that combine all RGB values. For example, to display yellow (red + green), use 'analogWrite(LED_R, 255); analogWrite(LED_G, 255); analogWrite(LED_B, 0);'.

Controlling the LED over the Internet

Now, let's explore controlling the LED over the internet. This involves setting up a web server or using a cloud service. One such platform is IFTTT (If This, Then That). You'll need to create an account and explore their web-based platform to set up your trigger-event and action.

Another method is using Blynk, a popular app for controlling IoT devices. You'll need to sign up, create a new project, and add the 'LED' widget. After configuring the widget, you can input the color and brightness values using Blynk's web or mobile app.

Congratulations! You've successfully controlled an RGB LED using your ESP32 S3 and understood its fundamentals. Now, the world of IoT and LED projects awaits you. Happy tinkering!