I tried today the LED widget is very helpfull for on/off state signaling. But for fading is very poor quality maybe the small led dimension is the reason and the 3D form.
My idea would be a bigger led not necesarly 3D, posibility to change the color, size and form (circle, square, line, maybe editable for custom signs) in setting mode. For more detailed pwm value display not necesarly to know the value is to highlight the edge of the led with a circle with the circumference depending on pwm value, like in the Particle Android app for the Spark Core or Photon.
The dimension of the widget is ok.
Is a RGB LED widget still planned (or am I just blind and can’t find it)? Three separate LED Widgets, each coloured Red,Green & Blue, just don’t have the same affect
@Dmitriy OK, I “think” I can create a RGB LED widget with whatever colour I need, as if it were a real world LED, by converting the usual 0-255 per pin data to HEX and combining the three HEX values into a single string that I use to send to the app (weeehaw, so far easier said then done … but I am still working on that).
But say I want to simply control a real world RGB (via the zebra widget for simplicity sake for now) AND get the RGB LED Widget to correspond with the same colours?? … sending zebra widget output directly to digital pins is easy, but say I instead send to virtual pins, forward that data to the real world RGB, as well as do the HEX conversion and feed that info back to the app?
And yes, I have tried reading the DOCs… but entering something like Serial.print(BLYNK_READ(V0)); so I can see the data, causes this strange “…Error compiling for board Arduino/Genuino Mega or Mega 2560.”
EDIT - I also tried this function, but had the same error when compiling… it doesn’t seem to like BLYNK_WRITE()
Using latest IDE and Librarys.
BLYNK_WRITE(V1) { int v1Value = param.asInt(); // assigning incoming value from pin V1 to a variable Serial.print("V1 is: "); Serial.println(v1Value); }
FINAL EDIT - OK, I am going to stop asking questions if I always seem to find the answer on my own (However it does seem to require the act of asking…Hmmmmm).
I am still working on the LED issue, but all I had to do for the compile issue was load a seperate window with your full example code and compile it… then, and only then would my code compile, WITHOUT making a single change… go figure.
You can’t call a Blynk function inside an “Arduino” function.
setProperty is fully documented and it is straightforward to change the colour of an LED.
@Costas Yes yes, as per my edits, I already figured out what I CAN’T do ; Still looking for assistance on what CAN be done. And while everything may be “well documented” to those in the know… IMHO, as a very inexperienced coderwannabe, it is quite fragmented between DOCS, Github, and other random pages - Thankfully composed from blessed others whom have traveled those wandering paths in the past .
Anyhow, I digress…
I HAVE managed to retrieve the virtual pin data from a widget and use it to activate a real-world pin on the hardware. And I am soooo close to forwarding the HEX conversion of said pin data back to the app (via the aforementioned “setProperty”, Thank you @Dmitriy). But I seem to only get “truncated” HEX (hey, I don’t know the proper terminology ) out of any single digit DEC number.
For example:
//Take data from BLYNK_WRITE() function call and convert to HEX String strRED = String(vRValue, HEX); String strGRN = String(vGValue, HEX); String strBLU = String(vBValue, HEX); //Combine converted HEX from the three pins into single string and //change the simulated RGB LED color Blynk.setProperty(V1, "color", String("#" + strRED + strGRN + strBLU)); // Activate simulated RGB LED. RGB.on();
This works perfectly for WHITE, as 255, 255, 255 = #FFFFFF However BLACK (or any other colour as that sneaky zebra seems to always put a 0 as one of the three pin outputs) such as an ugly TEAL= 0,129,151 which translates to #08197 NOT the required #008197
So, anyone have suggestion on how to prep the variables, properly use String() or use an alternative way to convert DEC to HEX in the required format?
@Costas Thank you for the suggestion, I did try it out just in case, but unfortunately it only works for the first pin’s data (RED), and only if it was a 0 in the first place, otherwise it just skews all the data to the right by one extra 0.
But as usual… I had already come up with a IF() solution that works to circumvent the sneaky zebra’s two legged entrance to a three legged race
For example on the RED pin conversion :
String strRED = String(vRValue, HEX); if (vRValue == 0) // If DEC answer is 0... { strRED = "00"; // ...force it to be string "00" }
This works perfectly for the zebra widget; however, I still need a solution for any other input source that will result in a single digit HEX (Granted, that may only be from a DEC 0-9… I haven’t worked it out yet, but if that is the case then perhaps just add a bunch of IF() ELSE queries - why be elegant when brute force is so much fun ).
Yup… I think I am going to keep asking questions… even if I end up answering them myself. Mainly because for every question I have asked, I have had dozens that I managed to figure out soon enough to avoid asking in the first place. But it is the real brain twisters that seem to require me to formulate a question so well (dyslexic issues), that my subconscious seems to figure out the answer shortly after asking, Ha! .
@Gunner with zeRGBa in merge mode and upper limits set to 255 on V0 this code:
BLYNK_WRITE(V0) // There is a Widget that WRITEs data to V0
{
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
Serial.println(r);
Serial.println(g);
Serial.println(b);
String strRED = String(r, HEX);
String strGRN = String(g, HEX);
String strBLU = String(b, HEX);
if(r < 16){
strRED = String("0" + strRED);
}
if(g < 16){
strGRN = String("0" + strGRN);
}
if(b < 16){
strBLU = String("0" + strBLU);
}
String LEDstring = String("#" + strRED + strGRN + strBLU);
Serial.println(LEDstring);
Blynk.setProperty(V1, "color", LEDstring);
Blynk.setProperty(V2, "color", LEDstring);
}
allows you to select any LED colour from the zeRGBa like this:
@Costas Ohhh, preeety code… no, seriously, I am still banging sticks together here and as one who deals with various learning disabilities (thankfully stupidity is NOT one of them, ha!), I find that Kinesthetic learning is best for myself.
In other words, people (or millions of Arduino web pages) can tell me everything about rocks… all… day… long… but until they hand me one and perhaps hit me upside the head with it as a demonstration I just won’t get it.
That said, I will look into your rock, er, code snippit and even, finally, figure out what this “Merge Mode” is and how it is applied… Thanks
As for other input sources of single digit DEC to specific formatted HEX, I’m not sure if it matters anymore, but having a quest helps me learn.
@Costas Ah, yes… that code works much smoother. Thanks for taking the time to provide a workable example that I could integrate.
It also confirms what I was just starting to test; that I could put all the relevant action in that one function, instead of all the separate void()s and timers I had going.
And you are correct, Merge Mode is relatively simple’ish, once I have something “virtually physical” to poke and fiddle with whilst watching the results.
Now, it is way to late (early) here; 5:30am… and I must sleep sometime.
@Costas Ahhh, my subconscious kicked in again whilst sleeping; I realized that to maintain the properly formatted HEX after DEC 0-255 conversation, it would only be the 0-15 that needed “padding” with a 0, after their HEX conversion.
Thus a slight modification the the IF() in the above code:
if (r < 16) { strRED = String("0" + strRED); }
And, finally… I think I am finished on this topic