How to wait until input is done/break a while loop with input?

Alright so I have a servo that I wan’t to move after the user is finished changing the value. I have a numeric input widget. The goal is to not have the servo move until the user is done pressing the + or minus buttons.

My original thought was:


BLYNK_WRITE(V3){
  currentMilli = millis();
  angle = param.asFloat();
  while (millis() < currentMilli + period) {
    intermediateAngle = param.asFloat();
  }
    if(intermediateAngle==angle){
     servo.write(angle);
}
}

But this just makes a pause of period between the servo writes. I’ve tried maybe making another function to talk to it but I just can’t get it to work as intended. Any ideas? Is there a way to have it so the while loop is broken when V3 is called?

Why not make life simple and gave a Go! button that triggers the servi to move once the desired angle has been set.
This also has the advantage of allowing the same angle to be repeated multiple times without the need to change the numeric input to a different value and back again.

Everything else requires a waiting period after the last increment, which makes it very unresponsive and will probably lead to user coinfusion.

Pete.

That’s a great idea! To be honest with you, I don’t need this feature but it would make it so much cooler if it worked. It’s for a thermostat I’ve been working on for a few months and I just would like it if it didn’t jerk around when going up say, three degrees.

But so there is no way to do this without a “confirm” button or something?

maybe use a slider, set to send on release, instead of a numeric input.

1 Like