Ideally I would like a virtual pin to start a loop and have the loop end when the value of the pin is changed. For this to happen, the loop needs to get the value of the pin to see it needs to stop looping. The problem is that BLYNK_WRITE can’t be called in a loop or a function. If it can be called, I’m not sure how to do it. I always run into an error saying I can’t define a function.
Here’s a simple example with a button, but it doesn’t work:
BLYNK_WRITE(V0){
pinData=param.asInt; //This should either be 1 or 0.
functionWithALoop(); //Calls on some function when the pin updated.
}
void functionWithALoop(){
while(pinData=1){
Code goes here; //Performs some task while the pin has a value of 1.
BLYNK_WRITE(V0){ //Checks to see if the pin value has changed.
pinData=param.asInt;
}
}
I learned C++ two days ago, so there might be a basic solution to this, but I just can’t find it anywhere. I’m just looking for a way to update a pin’s value inside a function that can be called in BLYNK_WRITE.