#include #include #include #define PIN 0 #define NUMPIXELS 7 typedef struct struct_message { int brushSize; uint32_t color; // Direct decimal color like 16777215 } struct_message; struct_message ledData; int lastBrushSize = -1; int brush = 0; Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); // Callback when data is received void OnDataRecv(const esp_now_recv_info_t *recvInfo, const uint8_t *incomingData, int len) { memcpy(&ledData, incomingData, sizeof(ledData)); Serial.print("📥 Brush Size: "); Serial.println(ledData.brushSize); Serial.print("🎨 Decimal Color: "); Serial.println(ledData.color); } void setup() { Serial.begin(115200); WiFi.mode(WIFI_STA); Serial.print("Receiver MAC Address: "); Serial.println(WiFi.macAddress()); if (esp_now_init() != ESP_OK) { Serial.println("❌ Error initializing ESP-NOW"); return; } esp_now_register_recv_cb(OnDataRecv); pixels.begin(); pixels.clear(); pixels.show(); } void loop() { if (ledData.brushSize != lastBrushSize || brush > 0) { lastBrushSize = ledData.brushSize; switch (ledData.brushSize) { case 1: brush = 1; break; case 2: brush = 4; break; case 3: brush = 7; break; default: brush = 0; break; } pixels.clear(); if (ledData.brushSize == 1) { pixels.setPixelColor(0, ledData.color); } else if (ledData.brushSize == 2) { pixels.setPixelColor(0, ledData.color); pixels.setPixelColor(1, ledData.color); pixels.setPixelColor(4, ledData.color); pixels.setPixelColor(5, ledData.color); } else if (ledData.brushSize == 3) { for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, ledData.color); } } pixels.show(); Serial.print("✨ Lighting up "); Serial.print(brush); Serial.println(" pixels."); } }