I’m struggling with a code ‘effenciency’ issue, I have about 30 on/off inputs. Each is processed through the exact same set of criteria and responded to identically changing property settings. But, the set property commands have these peskey pin references that dont seem to be dynamic. See the current code.
Blynk.setProperty(V30,"offLabel","Door 5 OPEN"); // warn condition
Blynk.setProperty(V30,"offBackColor","#FF0000"); // Background color red
The strings are easy. Whats not so easy is how to handle the virtual pin number, Ideally i’d like to do something like this.
Blynk.setProperty(V[i],propertyLabelString[i],condtionString[i]); // warn condition
Blynk.setProperty(V[i],propertyBackColorString[i],conditionBackColorString[i]); // Set Background color
If i can do this, it will prevent me from having to replicate 9, 30 level switch/case statements.
The Closest I can come is a big tall switch/case statement with the following.
Just seems wasteful…
void SetPropIdx(int i,String propString1, String propString2)
{
switch(i){
case 0:
Blynk.setProperty(V0,propString1,propString2);
break;
case 1:
Blynk.setProperty(V1,propString1,propString2);
break;
case 2:
Blynk.setProperty(V2,propString1,propString2);
break;
// ...
}
These commands only relate to virtual pins.
If you want to change the state of a digital pin then it’s a standard C++ digitalWrite() command and the Blynk library does the rest.
I guess the same for Analogue pins, but I’ve never tried that.