#6 Matrix of LARGE Randomly Flashing & Coloured Virtual RGB “Super LEDs” (AKA Buttons)
I don’t know why I didn’t do this one sooner… less energy and at about 80% less “LEDs” to flash, it should be theoretically faster… well… it costs less energy at least (3200 units of energy)
Challenge Question for the Developers… why is it seem faster to change the colour properties on 71 LEDs compared to 16 Buttons?
- http://docs.blynk.cc/#widgets-controllers-button
- http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynksetpropertyvpin-property-value
- https://www.arduino.cc/reference/en/language/functions/random-numbers/random/
Even the QR looks more complex… but then Buttons do have more settings then an LED
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266mDNS.h> // For OTA
#include <WiFiUdp.h> // For OTA
#include <ArduinoOTA.h> // For OTA
#define BLYNK_NO_BUILTIN // Disable built-in analog & digital pin operations
#define BLYNK_MAX_READBYTES 1024
#define BLYNK_MSG_LIMIT 0
#define BLYNK_HEARTBEAT 60
BlynkTimer timer;
char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
//char server[] = "xxx.xxx.xxx.xxx"; // IP for your Local Server
char server[] = "blynk-cloud.com"; // URL for Blynk Cloud Server
int port = 8080;
String HEXstring;
int randLED;
int randIntensity;
int rrr, ggg, bbb;
int RandomTimer;
void setup() {
WiFi.begin(ssid, pass);
// Preset for use on a Local Server... adjust as required for Cloud Server
Blynk.config(auth, server, port);
Blynk.connect();
for (int i = 0; i <= 16; i++) {
Blynk.virtualWrite(i, 1); // Set Button ON
Blynk.setProperty(i, "label", " "); // Set Button Label to blank
Blynk.setProperty(i, "color", "#000000"); // Set Button colour to black
}
RandomTimer = timer.setInterval(30L, RGBMatrix);
ArduinoOTA.setHostname("ESP8266 BIG vRGB Matrix"); // For OTA
ArduinoOTA.begin(); // For OTA
}
void loop() {
Blynk.run();
timer.run();
ArduinoOTA.handle();
}
void RGBMatrix() {
randLED = random(17);
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
}