How to Control an RGB LED Lamp With Your Browser Using Arduino UNO R4 WiFi
by dziubym in Circuits > Arduino
66 Views, 0 Favorites, 0 Comments
How to Control an RGB LED Lamp With Your Browser Using Arduino UNO R4 WiFi

After four years and 100+ videos without a single IoT project, I finally dove into the Internet of Things (IoT) world! This guide is perfect for beginners — especially fellow Boomers — who might not even know what IoT stands for (it's Internet of Things, by the way).
In this project, we'll:
- Connect an Arduino UNO R4 WiFi to the internet
- Create a simple web server
- Control a single LED or a WS2812 RGB matrix using your browser
- Even 3D print a custom lamp enclosure!
📺 Prefer video tutorials?
You can follow this project step-by-step on YouTube:
- ▶️ From Arduino to Web-Controlled IoT Lamp: Learn Internet Connectivity with Arduino Uno R4 WIFI!: https://youtu.be/JUgAKao-3bc
Supplies


- Arduino UNO R4 WiFi
- LilyPad LED or WS2812 LED Matrix
- Jumper wires
- Breadboard (optional)
- USB cable
- Access to WiFi
- 3D printer (optional)
- Double-sided tape
- Computer with Arduino IDE installed
- FastLED library (for WS2812)
Understanding How Arduino Connects to WiFi (with UNO R4 WiFi)

Before diving into the code, it's important to understand how the Arduino UNO R4 WiFi fits into your local network environment. The diagram below illustrates the topology we'll be working with.
📡 Network Architecture Overview:
Your Arduino UNO R4 WiFi connects to your home WiFi router, just like your smartphone and laptop. This puts all the devices on the same local subnet — in this case, 192.168.68.0/24.
🔍 What This Diagram Shows:
- Router (Gateway)
- IP: 192.168.68.1
- Connects all local devices wirelessly and provides internet access (if needed)
- Arduino UNO R4 WiFi
- IP: 192.168.68.128 (example, dynamic via DHCP)
- Will run a web server for LED control or data display
- Smartphone
- IP: 192.168.68.130
- Can access the Arduino's web interface via a browser
- Laptop
- IP: 192.168.68.120
- Also capable of accessing the Arduino over WiFi via the browser or tools like ping and serial monitor
- Subnet: 192.168.68.0/24
- All devices share the same subnet, meaning they can talk to each other directly without routing through the internet
🧠 Why This Matters:
By ensuring all devices are on the same subnet:
- You can easily communicate with the Arduino using just its local IP address (e.g., http://192.168.68.128)
- You avoid needing any port forwarding, cloud services, or external servers
Display WiFi Connection Info in Serial Monitor

In this step, we connect your Arduino UNO R4 WiFi to your wireless network and display critical connection information using the Serial Monitor.
🔧 What This Code Does:
- Connects to your WiFi network using SSID and password
- Waits until the connection is successful
- Prints network info: SSID, IP address, signal strength (RSSI), encryption type
- Shows MAC addresses for both the Arduino and your router
🧠 Arduino Code:
🧪 Testing:
- Upload the sketch to your Arduino UNO R4 WiFi.
- Open the Serial Monitor at 9600 baud.
- Watch for the WiFi connection progress and detailed network info.
Control a Single LED From Your Web Browser






Let’s raise the stakes: now that the Arduino is connected to WiFi, we’ll set up a basic web server on it and use it to remotely toggle an LED — no extra software or apps, just your web browser!
This is a great first step into IoT: transforming your microcontroller into a responsive device on your local network.
🛠️ Hardware Setup
To keep things simple and elegant, we’ll use a LilyPad LED, which plugs directly into the female header pins on the UNO R4:
- Anode (+) → Digital Pin 10
- Cathode (–) → GND
No breadboard, no mess!
🧠 What You'll Achieve
You’ll be able to:
- Turn the LED on using: http://<your-arduino-ip>/H
- Turn the LED off using: http://<your-arduino-ip>/L
This is done using standard HTTP GET requests, and the Arduino replies with a basic HTML page confirming the LED state.
💻 Complete Arduino Code
📌Code Highlights
- #include <WiFiS3.h>
Loads the library that enables WiFi functionality on the Arduino UNO R4 WiFi (based on the ESP32-S3 chip).
- WiFiServer server(80);
Sets up a basic HTTP server on port 80 (standard for web traffic).
- WiFi.begin(ssid, pass);
Connects to your WiFi using the provided SSID and password.
- server.available();
Checks if a device (browser) is trying to connect to the Arduino.
- client.readStringUntil('\r');
Reads the HTTP request from the client (browser). For example, /H or /L.
- request.indexOf("/H") != -1
If the request contains /H, the LED is turned ON.
- request.indexOf("/L") != -1
If the request contains /L, the LED is turned OFF.
- client.println("HTTP/1.1 200 OK");
Sends back an HTTP success response and basic HTML content showing the LED's status.
🌐 How to Use It
- Upload the sketch to the Arduino UNO R4 WiFi.
- Open Serial Monitor to find the assigned IP address.
- Open a browser on any device connected to the same WiFi and enter:
- http://<arduino-ip>/H → LED turns ON
- http://<arduino-ip>/L → LED turns OFF
🧪 Pro Tip: Some browsers (like Safari) might pre-fetch URLs for autocomplete. If the LED turns on before pressing Enter, it’s likely due to this preview behavior.
Design and Print a Custom LED Lamp




Created in Tinkercad, the lamp has:
- A base for mounting the matrix
- A shade to diffuse light
- Cable management holes
Upgrade to a Color Matrix Lamp With FastLED




After successfully controlling a single LED, let’s level up this project by using a WS2812 LED matrix. These individually addressable RGB LEDs allow us to set dynamic colors and build a lamp with serious visual appeal.
We'll also replace the basic /H and /L commands with color-specific URLs like /RED, /WHITE, /BLACK, and more — giving your project a richer, more customizable interface.
What You'll Achieve
- Replace the single LED with a 64-pixel WS2812 matrix
- Control the color of the whole matrix via your browser
- Create a proper web-controlled RGB lamp
🛠️ Hardware Setup
- Connect Data IN on the WS2812 matrix to digital pin 5 on the Arduino UNO R4 WiFi
- Connect 5V and GND to the matrix (ensure enough current if powering many LEDs)
- Use double-sided tape or a 3D-printed base to mount the matrix neatly
⚠️ Important: WS2812 strips/matrices can draw a lot of power. Power them with care—either from Arduino for small setups or an external 5V supply for larger ones.
💻 Arduino Code (WS2812 Matrix Web Control)
📌 Code Highlights
- FastLED Library: Controls the WS2812 matrix. Include it with #include <FastLED.h>.
- addLeds<>() Setup: Specifies LED type, pin, and color order.
- New Commands: Instead of /H and /L, now use:
- /RED
- /GREEN
- /WHITE
- /BLACK
- Loop Logic: Each browser request changes the NewColor, updates all 64 LEDs, and sends an HTML status response.
- Brightness Control: Adjustable via #define BRIGHTNESS.
🖥️ How to Use
- Upload the code.
- Power on the Arduino.
- Open the Serial Monitor to note the IP address.
- In any browser, visit:
- http://<arduino-ip>/RED
- http://<arduino-ip>/GREEN
- http://<arduino-ip>/WHITE
- http://<arduino-ip>/BLACK (turns off lamp)
🔧 Extra Notes for WS2812 Setup
- Install the FastLED library via Arduino Library Manager or manually if compatibility issues arise with the UNO R4 WiFi.
- Ensure GRB is the correct color order for your matrix. Some use RGB instead.
- If brightness appears low or flickery, check power supply capacity and ground continuity.
What's Next?
This project is just the beginning!
Future Improvements:
- Replace UNO R4 with WEMOS D1 for a smaller build
- Add support for the Blynk app
- Integrate with Alexa voice commands
- Configure port forwarding to allow global access
- Run a YouTube live session where viewers change lamp colors in real time!
🧠 Pro Tip: Use a static IP address to avoid having to recheck your Arduino’s IP every time.
Conclusion
You’ve now built an Internet-connected RGB lamp controlled entirely from your browser! While it starts simple, this project opens up the world of IoT, home automation, and interactive web-based controls.
👋 Follow me for more IoT adventures and 3D printing hacks!