Simple UNTIL, but how?


I just want to make a simple code:
A slide door opener with a servo motor.

How can one make the following code with Arudino:

IF "button up=1" THEN ServomotorUp UNTIL "SensorDoorUp=1".


The Servo is up and running (continuous rotation)

IF "button up=1" THEN ServomotorUp UNTIL "SensorDoorUp=1".

Some languages actually have an "until" statement, but C/C++ only has "while", so you have to reverse the sense of your test... something like:

if (digitialRead(UPBUTTON)) {
   do {
   } while (digitalRead(DOORUP) == 0);
} // end of if

It will be more complicated if you want to check other buttons at the same time the door is moving, or stop if the button stops being pressed, or whatever.

Is it a button you need to press during the whole opening and you want it to stop in end position? You can try this.

if (button_up==1 && SensorDoorUp!=1) { //button pressed and not at end position
   digitalWrite (ServomotorUp,HIGH);
else { 
   digitalWrite (ServomotorUp,LOW);