I made a tiny pixel LED lamp for decorating my desk. It is a tiny, cute LED lamp that you can build
We are using WS2812B LED for this project. With the package size of 2020, we are using about 22 LEDs for this project. Seeed Studio XIAO ESP32C3 controls all of these LEDs with custom code,
Let's get into the details.
3D printing of the enclosureI used Fusion 360 to design the enclosure for this project and exported the STL files for 3D printing
Then I uploaded the STL files to JLC3DP.com and used 8001 transparent resin as the material for this print. After a few days of waiting, I received the print. It looks good
Used EasyEDA to design the PCB for this project, then exported the Gerber file for manufacturing
I used a white PCB for the project and utilised PCBA assembly from JLCPCB for assembling the PCB, which made the process much easier. The WS2812B 2020 LEDs are quite difficult to solder by hand, and there is a risk of damaging the LEDs during hand soldering.
It looks good !!!!
Wring everything up
Connected the XIAO with the Pixel LED. Here is the information about these connections
- 5v to 5v
- GND to GND
- D0 to DIN
Place the XIAO onto the main body and secure it using the support with M2 screws
Insert the PCB into the tube
Close the upper and lower parts together using some glue.
So we are done with the assembly now. Connect this to your PC and program it
Here is the code for this project
#include <Adafruit_NeoPixel.h>
#include <math.h>
// ================= CONFIG =================
#define LED_PIN D10
#define LED_COUNT 22
#define BRIGHTNESS 50
// ==========================================
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// -------- Aurora color control --------
uint16_t currentHue = 0;
uint16_t targetHue = 0;
uint32_t lastHueChange = 0;
// NeoPixel sine helper (0–255)
uint8_t sin8_neo(uint16_t x) {
return (sin(x * 0.0245436926) + 1.0) * 127.5;
}
// Smooth hue interpolation with wrap-around
uint16_t lerpHue(uint16_t a, uint16_t b, uint8_t amount) {
int32_t diff = (int32_t)b - (int32_t)a;
if (abs(diff) > 32768) diff -= (diff > 0) ? 65536 : -65536;
return a + (diff * amount) / 255;
}
// ================= SETUP =================
void setup() {
strip.begin();
strip.setBrightness(BRIGHTNESS);
strip.clear();
strip.show();
randomSeed(analogRead(A0));
currentHue = random(0, 65535);
targetHue = random(0, 65535);
}
// ================= LOOP =================
void loop() {
auroraFlow();
strip.show();
delay(20);
}
// ================= AURORA EFFECT =================
void auroraFlow() {
// Pick a new random target hue every 5 seconds
if (millis() - lastHueChange > 5000) {
targetHue = random(0, 65535);
lastHueChange = millis();
}
// Smoothly move current hue toward target hue (VISIBLE speed)
currentHue = lerpHue(currentHue, targetHue, 5);
for (int i = 0; i < LED_COUNT; i++) {
uint8_t wave1 = sin8_neo(i * 15 + millis() / 10);
uint8_t wave2 = sin8_neo(i * 10 + millis() / 16);
uint8_t wave3 = sin8_neo(i * 6 + millis() / 22);
uint16_t hue = currentHue + wave1 * 35;
uint8_t sat = 170 + wave2 / 3;
uint8_t val = 110 + wave3 / 2;
strip.setPixelColor(
i,
strip.gamma32(strip.ColorHSV(hue, sat, val))
);
}
}We are finished now. You can power the device using a USB. Enjoy!
A huge thanks to JLCPCB for fabricating the PCB and JLC3DP for supporting this project with their amazing 3D printing service.
JLC3DP is the future of manufacturing, offering a user-friendly online platform for advanced 3D printing with:
- ✅ Instant quoting & real-time tracking
- ✅ 48-hour lead time & door-to-door delivery
- ✅ 20+ material options
- ✅ Enterprise-grade quality
- ✅ Prices starting at just $0.3, with up to $70 in new user coupons!
✨ Try them out at JLC3DP.com LC3DP
thanks




_t9PF3orMPd.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)



Comments