Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsThe DFRobot Fermion 2.0-inch display is a 320x240 IPS panel with an ST7789 controller and a microSD slot on the same board, sharing one SPI bus. The ESP32 lists the .bmp files on the card and draws them one row at a time. 24-bit BMP is the easiest picture format to decode because it stores plain colour values; the sketch converts each pixel to the display's 16-bit colour.
Tick anything you already have and the total updates.
DFRobot Fermion 2.0-inch 320x240 IPS display with microSD
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB.
frame.inoVerify & upload in Electrolark#include <SPI.h>
#include <SD.h>
#include <Adafruit_ST7789.h>
Adafruit_ST7789 tft(5, 2, 4);
const int SD_CS = 15;
uint16_t rd16(File &f) { uint16_t r; f.read((uint8_t*)&r, 2); return r; }
uint32_t rd32(File &f) { uint32_t r; f.read((uint8_t*)&r, 4); return r; }
void drawBmp(const char* path) {
File f = SD.open(path);
if (!f) return;
if (rd16(f) != 0x4D42) { f.close(); return; } // 'BM'
rd32(f); rd32(f);
uint32_t offset = rd32(f);
rd32(f);
int32_t w = rd32(f), h = rd32(f);
uint16_t planes = rd16(f), depth = rd16(f);
uint32_t comp = rd32(f);
if (planes != 1 || depth != 24 || comp != 0 || w > 320) { f.close(); return; }
uint32_t rowSize = (w * 3 + 3) & ~3;
static uint8_t buf[320 * 3];
static uint16_t line[320];
for (int y = 0; y < h && y < 240; y++) {
f.seek(offset + (h - 1 - y) * rowSize); // BMP rows are stored bottom first
f.read(buf, w * 3);
for (int x = 0; x < w; x++) line[x] = tft.color565(buf[x * 3 + 2], buf[x * 3 + 1], buf[x * 3]);
tft.drawRGBBitmap(0, y, line, w, 1);
}
f.close();
}
void setup() {
tft.init(240, 320);
tft.setRotation(1);
tft.fillScreen(ST77XX_BLACK);
if (!SD.begin(SD_CS)) { tft.print("No SD card"); while (1); }
}
void loop() {
File dir = SD.open("/");
for (File e = dir.openNextFile(); e; e = dir.openNextFile()) {
String n = String("/") + e.name();
e.close();
if (n.endsWith(".bmp") || n.endsWith(".BMP")) { drawBmp(n.c_str()); delay(10000); }
}
dir.close();
}
Format as FAT32, check SD CS is GPIO15 and that MISO is connected.
It is not a 24-bit uncompressed BMP or it is wider than 320; save it again.
Some panels want BGR; swap the first and third values in color565.
Yes, with a JPEG decoder library such as TJpg_Decoder, but BMP is simpler to start.
A 320x240 BMP is about 230 KB, so thousands fit on a small card.
Yes, add a small web upload page on the ESP32 that writes to the card.
5 parts: ESP32-WROOM-32 38-Pin Development Board, DFRobot Fermion 2.0″ 320×240 IPS TFT LCD Display with MicroSD Slot – SPI & GDI Interface, Official Raspberry Pi 32GB A2 Class Micro SD Card, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (frame.ino).
About ₹3,404 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Two SPI devices on one bus with separate chip selects; Reading the BMP file format; Converting 24-bit colour to RGB565.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.