Projects / Pixel art lamp

Pixel art lamp

Intermediate4 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP32

    Tile the panels

    2 by 2 and chain them.

  2. ESP32

    Test one pixel

    Walk it along the first row.

  3. ESP32

    Fix the XY map

    Until a row looks like a row.

  4. ESP32

    Serve the page

    Upload from a phone.

  5. ESP32

    Convert to 16 by 16

    In the browser.

  6. ESP3212.5 mA

    Limit the power

    FastLED max milliamps.

  7. ESP32

    Add a diffuser

    Frosted acrylic or paper.

In short

How do you build a pixel art lamp?

A 16 × 16 LED panel shows pixel art and animations loaded from a phone over Wi-Fi. You need ESP32 DevKit V1, WS2812B 8x8 RGB LED matrix × 4, 5 V 2 A USB adapter, Resistor 330 Ω and Electrolytic capacitor 1000 µF. It takes 7 steps and about 240 minutes.

Level
Intermediate
Time
About 240 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
ESP32 GPIO5330 Ω resistor to the first panel DINData
Panel 1 DOUTPanel 2 DIN, then 3, then 4Daisy chain
All panels 5V and GND5 V adapterLED power
1000 µF capacitorAcross the 5 V and GND at the first panelAbsorbs switching spikes
ESP32 GNDPanel GNDCommon ground
ESP32 VIN5 V adapter plusPower the board

Code

Four 8 by 8 panels make a 16 by 16 grid; the XY function turns a column and row into the LED's place in the chain, accounting for the panel order and the zig-zag wiring inside each panel, which is the usual fiddly part, so test it with one coloured pixel moving along a row before anything else and adjust the function if the picture is mirrored or scrambled. The phone page shrinks any photo to 16 by 16 pixels in the browser, so the lamp only has to receive 768 numbers. Put your own Wi-Fi name and password in the placeholders and keep them out of anything you share; the page has no password, so use it on your home network only. All 256 LEDs at full white would need over 15 A, so the sketch tells FastLED to limit the total to 2.5 A; use a 5 V 4 A adapter with the capacitor and the data resistor in place, and keep the lamp in a case with a diffuser so the LEDs do not hurt the eyes. Add short animations later by sending several frames. Arduino IDE with the ESP32 boards package 2.0.x, board "ESP32 Dev Module".

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Pixel art lamp: upload an image from a phone browser and show it on a 16x16 grid of four 8x8 panels. Library: FastLED.
// Board: ESP32 Dev Module. Panels in order: top-left, top-right, bottom-left, bottom-right; each panel zig-zags row by row.
#include <WiFi.h>
#include <WebServer.h>
#include <FastLED.h>
const char* SSID = "YOUR_WIFI_NAME";
const char* PASS = "YOUR_WIFI_PASSWORD";
#define NUM_LEDS 256
CRGB leds[NUM_LEDS];
WebServer server(80);
int XY(int x, int y) {
  int panel = (y / 8) * 2 + (x / 8);                // 2 panels per row
  int r = y % 8, c = x % 8;
  int inRow = (r % 2) ? (7 - c) : c;                // adjust if your panel is not zig-zag
  return panel * 64 + r * 8 + inRow;
}
const char PAGE[] PROGMEM = R"HTML(<html><body style="font-family:sans-serif">
<h3>Pixel lamp</h3>
<input type="file" id="f" accept="image/*"><canvas id="c" width="16" height="16" style="width:160px;image-rendering:pixelated"></canvas>
<button onclick="send()">Show it</button><p id="m"></p>
<script>
var cv=document.getElementById('c'),cx=cv.getContext('2d');
document.getElementById('f').onchange=function(e){var im=new Image();im.onload=function(){cx.drawImage(im,0,0,16,16);};im.src=URL.createObjectURL(e.target.files[0]);};
function send(){var d=cx.getImageData(0,0,16,16).data,s='';
for(var i=0;i<d.length;i+=4){for(var k=0;k<3;k++){var h=d[i+k].toString(16);s+=(h.length<2?'0':'')+h;}}
fetch('/set',{method:'POST',body:s}).then(function(r){return r.text();}).then(function(t){document.getElementById('m').innerText=t;});}
</script></body></html>)HTML";
void handleSet() {
  String body = server.arg("plain");
  if (body.length() != 16 * 16 * 6) { server.send(400, "text/plain", "Bad image"); return; }
  for (int y = 0; y < 16; y++) for (int x = 0; x < 16; x++) {
    int p = (y * 16 + x) * 6;
    uint8_t r = strtol(body.substring(p, p + 2).c_str(), NULL, 16);
    uint8_t g = strtol(body.substring(p + 2, p + 4).c_str(), NULL, 16);
    uint8_t b = strtol(body.substring(p + 4, p + 6).c_str(), NULL, 16);
    leds[XY(x, y)] = CRGB(r, g, b);
  }
  FastLED.show();
  server.send(200, "text/plain", "Shown");
}
void setup() {
  FastLED.addLeds<WS2812B, 5, GRB>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 2500);  // FastLED scales brightness to protect the supply
  FastLED.clear(); FastLED.show();
  WiFi.begin(SSID, PASS);
  while (WiFi.status() != WL_CONNECTED) delay(300);
  server.on("/", []() { server.send_P(200, "text/html", PAGE); });
  server.on("/set", HTTP_POST, handleSet);
  server.begin();
}
void loop() { server.handleClient(); }

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
One pixelMoves left to right along the first row
Uploaded photoAppears right way up
Full whiteDimmed to the power limit
AdapterStays cool

If it does not work

Image mirrored or scrambled

Fix the XY function for your panels.

Page will not load

Check Wi-Fi details and the IP address.

Flicker

Check capacitor and data resistor.

Colours wrong

Change GRB to RGB.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pixel art lamp?

ESP32 DevKit V1, WS2812B 8x8 RGB LED matrix × 4, 5 V 2 A USB adapter, Resistor 330 Ω and Electrolytic capacitor 1000 µF. 5 V 2 A USB adapter: Use 5 V 4 A.

How long does the pixel art lamp take to build?

About 240 minutes for a intermediate maker, in 7 steps.

How do I know the pixel art lamp works?

One pixel: Moves left to right along the first row. Uploaded photo: Appears right way up. Full white: Dimmed to the power limit.

Image mirrored or scrambled: what should I check?

Fix the XY function for your panels.

Page will not load: what should I check?

Check Wi-Fi details and the IP address.

Flicker: what should I check?

Check capacitor and data resistor.

Colours wrong: what should I check?

Change GRB to RGB.