Repeating code until condition is true

yanamada22:
Hi, I am working on a sketch that has two if loops. See code below:

#define led_bottom 19                             //led pin

int long unsigned time_1;                         //initial time
int long unsigned time_2;                         //final time
int long unsigned Time;                           //Delta Time

void setup () {
  Serial.begin(9600);
  pinMode(led_bottom, INPUT);                     //Set bottom led pin as input
  digitalWrite(led_bottom, HIGH);
}
void loop() {
  if (digitalRead(led_bottom)==HIGH) {            //Checks if bottom led is high
    time_1=micros();                              //If high, takes time measurement
    delay(30);                                    //delay for bouncing
  }
  if(digitalRead(led_bottom)==LOW) {              //Checks if bottom led is LOW
    time_2=micros();                              //If low, takes time measurement 
    delay(30);                                    //delay for bouncing
  }
  Time=time_2-time_1;
   Serial.print("T1= ");                         //Text to monitor
   Serial.println(time_1);                       //prints time 1
    Serial.print("T2= ");                     
    Serial.println(time_2);                      //Prints time 2
    Serial.print("Delta T=  ");
    Serial.println(Time);                        //Prints final-initial timme
}




My question is, how can i get the first if statement to wait until the condition is true before it moves on, I need the second if statement to do the same.

You can put a line with return after the delays.