Arnov Sharma
Published © MIT

Portable Studio Light

Studio Light Mini lets you pick colors and control RGB lights easily through a web app. Just tap, set, and glow.

BeginnerFull instructions provided1 hour302
Portable Studio Light

Things used in this project

Hardware components

Espressif esp12F
×1
NextPCB PCB Service
×1

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

cad file

Schematics

SCH

Code

code

C/C++
#include <Adafruit_NeoPixel.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
// WiFi credentials
const char* ssid = "URSSID";
const char* password = "URPASS";
// Web server
ESP8266WebServer server(80);
// NeoPixel setup
#define NeoPIN 14
#define NUM_LEDS 4
int brightness = 250;
//Use GRB ordering for WS2812B
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, NeoPIN, NEO_GRB + NEO_KHZ800);
const int led = 13;
void setup() {
Serial.begin(115200);
strip.setBrightness(brightness);
strip.begin();
strip.show();
delay(10);
Serial.println("NeoPixel initialized");
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi: ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected to: ");
Serial.println(ssid);
Serial.print("Web App IP Address: ");
Serial.println(WiFi.localIP().toString());
if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
void handleRoot() {
digitalWrite(led, HIGH);
String color = server.arg("c");
if (color.length() == 7 && color[0] == '#') {
setNeoColor(color);
}
int sec = millis() / 1000;
int min = sec / 60;
int hr = min / 60;
char clr[7] = "FFFFFF";
if (color.length() == 7) {
color.toCharArray(clr, 7);
}
// Reduced buffer size for safety
char webpage[1200];
snprintf(webpage, sizeof(webpage),
"<!DOCTYPE html>\n<html>\n\
<head>\n\
<title>STUDIO LIGHT MINI</title>\n\
<meta name='viewport' content='width=device-width, initial-scale=1.0'>\n\
<style>\n\
body { background-color:#111; color:#00ffe7; font-family:Arial; text-align:center; margin:0; padding:0; }\n\
h1 { margin-top:20px; font-size:2em; }\n\
input[type=color] { margin-top:20px; padding:10px; border:none; border-radius:6px; background:#222; color:#fff; }\n\
.btn { font-size:16pt; margin:20px; padding:10px 20px; background:#00ffe7; color:#111; border-radius:8px; cursor:pointer; }\n\
.btn:hover { background:#00ccbb; }\n\
</style>\n\
</head>\n\
<body>\n\
<h1>STUDIO LIGHT MINI</h1>\n\
<p>Uptime: %02d:%02d:%02d</p>\n\
<form method='post'>\n\
<input type='color' name='c' value='#%s' onchange='this.form.submit();'>\n\
<div class='btn' onclick='this.closest(\"form\").submit();'>CHANGE</div>\n\
</form>\n\
</body>\n</html>",
hr, min % 60, sec % 60, clr);
server.send(200, "text/html", webpage);
digitalWrite(led, LOW);
}
void handleNotFound() {
digitalWrite(led, HIGH);
String message = "File Not Found\n\n";
message += String("URI: ") + server.uri() + "\n";
message += String("Method: ") + (server.method() == HTTP_GET ? "GET" : "POST") + "\n";
message += "Arguments: " + String(server.args()) + "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, LOW);
}
void setNeoColor(String value) {
int number = (int) strtol(&value[1], NULL, 16);
int r = number >> 16;
int g = number >> 8 & 0xFF;
int b = number & 0xFF;
Serial.printf("RGB: %d %d %d\n", r, g, b);
//Send colors as GRB, matching hardware expectations
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, strip.Color(g, r, b));
}
strip.show();
delay(10);
Serial.println("Color updated.");
}

Credits

Arnov Sharma
352 projects • 360 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments