OK, some of you are aware that while I have been around here for awhile, it has always been with Arduinos and USB link… but thanks to some fellow Blynkers, I have been gifted with some bigger ESPs to actively learn on (all the better to assist others my dear).
So, while not my “first” ESP project, it was one that sorta satisfied my love of blinky LED’s; I was also testing the per-second Blynk.virtualWrite()
capacity of a couple of ESP models.
I give to you… the Virtual RGB Matrix…
Sorry to those not on Local Server… it is not cheap on the energy, however nothing in it is non-recyclable… 72 LED widgets @ 200 energy means you need 14,400 units of energy to load this in.
This code is compiled on a Wemos D! mini with OTA programming functionality built in… but it basically should work on most any ESP8266.
#define BLYNK_NO_BUILTIN // Disable built-in analog & digital pin operations
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxx";
char ssid[] = "xxxxxxxx";
char pass[] = "xxxxxxxx";
String HEXstring;
int randLED;
int randIntensity;
int rrr;
int ggg;
int bbb;
int RandomTimer;
BlynkTimer timer;
void setup()
{
ArduinoOTA.begin();
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "10.10.3.13", 8442);
RandomTimer = timer.setInterval(100L, RGBMatrix); // Set this to as low as you can for your network and device... I was able to go as low as 35ms on a ESP32
for (int i = 0; i <= 71; i++) {
Blynk.setProperty(i, "label", " "); // Set LED Labels to blank
}
}
void RGBMatrix()
{
randLED = random(72);
randIntensity = random(64, 256);
rrr = random(256);
ggg = random(256);
bbb = random(256);
String strRED = String(rrr, HEX); // Convert RED DEC to HEX.
if (rrr < 16) {
strRED = String("0" + strRED); // Buffer with 0 if required.
} // END if
String strGRN = String(ggg, HEX); // Convert GREEN DEC to HEX.
if (ggg < 16) {
strGRN = String("0" + strGRN); // Buffer with 0 if required.
} // END if
String strBLU = String(bbb, HEX); // Convert BLUE DEC to HEX.
if (bbb < 16) {
strBLU = String("0" + strBLU); // Buffer with 0 if required.
} // END if
String HEXstring = String("#" + strRED + strGRN + strBLU); // Combine HEX fragments.
Blynk.setProperty(randLED, "color", HEXstring); // Set LED Label to HEX colour
Blynk.virtualWrite(randLED, randIntensity);
}
void loop()
{
Blynk.run();
timer.run();
ArduinoOTA.handle();
}