I have within my test setup (using Local.Server), a zeRGBa controlling a physical RGB, then takes those three pin values, converts them to HEX and feeds that back to a widgetLED (my virtual RGB) using, for example, Blynk.setProperty(Vx, "color", HEXvalue);
And it all worked perfectly… until it stopped (always looks OFF), apparently after updating to Blynk app 2.1.0.
Strangely, in edit mode it (the widgetLED) will show the correct colour (in that ring to the right of the label) as last set by the zeRGBa.
Also Blynk.setProperty(Vx, "label", "My New Widget Label"); works fine.
Seriously?? NOBODY else uses Blynk.setProperty(Vx, "color", HEXvalue); with a widgetLED? Hmmm
I have created another simple sketch, using a different Arduino, connected via USB, running Cloud server… basically everything different.
But the same results; I can send the zeRGBa data to a switch or a display (widget) and change their colours just fine, but no longer can I control a LED (widget).
I am sure I am not crazy, because the voices in my head tell me so…
So… Just looking for feedback (on the vLED, not on my mental status )
The value depends on the conversion from the zeRGBa pin values into a combined and formatted HEX value. i.e. R-255 G-255 B-255 = #FFFFFF
I have posted the conversion code somewhere already, but can post it again here if you really need. But the code and values are correct as it changes the colour of any other switch or text display… and even sends the correct data to the widgetLED (as confirmed when I check it in edit mode)… It just no longer shows on the widgetLED when the project runs.
And as I was replying, it started working again… but only on the cloud server. So I guess I will go grab the snapshot for my local server (I was already at the latest 0.21.3 as of a few hours ago)
Thank you… it is the little things that matter at times
#include <BlynkSimpleStream.h>
#define RedP 3
#define GrnP 5
#define BluP 6
WidgetLED vRGB(V1);
//char auth[] = "xxxxx"; // LOCAL Server
char auth[] = "xxxxx"; // CLOUD Server
void setup()
{
Serial.begin(38400);
Blynk.begin(Serial, auth);
pinMode(4, OUTPUT); // Real World RGB LED
}
BLYNK_WRITE(V0) // zeRGBa widget (in Merge Mode) that feeds back HEX colour data to virtual RGB LED.
{
int r = param[0].asInt(); // get a RED channel value.
int g = param[1].asInt(); // get a GREEN channel value.
int b = param[2].asInt(); // get a BLUE channel value.
analogWrite(RedP, 255 - r); // Write to RED RGB pin.
analogWrite(GrnP, 255 - g); // Write to GREEN RGB pin.
analogWrite(BluP, 255 - b); // Write to BLUE RGB pin.
String strRED = String(r, HEX); // Convert RED DEC to HEX.
if (r < 16) {
strRED = String("0" + strRED); // Buffer with 0 if required.
}
String strGRN = String(g, HEX); // Convert GREEN DEC to HEX.
if (g < 16) {
strGRN = String("0" + strGRN); // Buffer with 0 if required.
}
String strBLU = String(b, HEX); // Convert BLUE DEC to HEX.
if (b < 16) {
strBLU = String("0" + strBLU); // Buffer with 0 if required.
}
String LEDstring = String("#" + strRED + strGRN + strBLU); // Combine HEX fragments.
LEDstring.toUpperCase(); // Change HEX value to all upper case for ease of visuals.
Blynk.setProperty(V1, "color", LEDstring); // Send formatted HEX to Virtual RGB LED.
Blynk.setProperty(V3, "color", LEDstring); // Send colour to Widget RGB display.
Blynk.virtualWrite(V3, LEDstring); // Send formatted HEX to Widget RGB display.
}
void loop()
{
Blynk.run();
}
Well, a day or so after calling this solved… it failed again (with no changes to code).
While re-testing ad-nauseum (new sketches/app projects; cloud and local server; Ethernet and USB; Uno, Mega and ProMicro; and three different Androids…) I was about to re-open the issue. Yes, I am tenacious… or perhaps a pain in the
Then while working on a unrelated virtual LED chase routine (with the basic colours), I accidentally merged some code and Eureka! A virtual LED changed colour & intensity as it should!!
I since realized that all I needed to do (for now at least) is include a Blynk.virtualWrite(255) before or after eachBlynk.setProperty() call (and it must be 255 even if the setProperty value represents a dim colour… it will still look proper).
i.e.
Blynk.setProperty(V0, "color", #2D0000); // Very dull/dim RED
Blynk.virtualWrite(V0, 255); // needs this line else nothing displays
If this was normal… then how did it work before?? (rhetorical)
If this is the NEW normal, then please update the DOCs
If it doesn’t make any sense, then I agree
Anyhow, I am posting this addendum for any who follow with the same, or similar, issue while programming a virtual LED widget with the whole range of colour/intensity options.