I would like to use one BLYNK_READ with dynamic (variable) virtual pin number, i.e., put to the function its argument as a variable. Is it possible please? I have found out in my project with Photons, that the argument (virtual pin) should be a literal, either for instance V1 or 1. If it is a variable, the mobile app widget does not update its value. I would like to use the same code (Particle IDE app) on two Photons but managed with one Blynk project where each Photon uses different virtual pins.
The sample code is as follows:
byte pinVirtual;
void setup() {
Blynk.begin(auth);
deviceId = System.deviceID();
if (deviceId.equalsIgnoreCase(photon1Id)) {
pinVirtual = 1; // or V1
}
if (deviceId.equalsIgnoreCase(photon2Id)) {
pinVirtual = 2; // or V2
}
}
void loop() {
Blynk.run();
}
BLYNK_READ(pinVirtual) // Does not work with variable
//BLYNK_READ(1) // Works with numeric literal
//BLYNK_READ(V1) // Works with string literal
{
Blynk.virtualWrite(pinVirtual, data); // Works in either case
}
Please, is the argument of BLYNK_READ a regular variable or is it a matter of preprocessor and compilation?