(Beginner) How to run both sensor and addressable LED strips at a same time?

Hello,

I'm trying to obtain the sensors readings as well as making the LED strips to light up at this particular pattern if the sensor readings reaches certain values. But since both of these codes are inside the void loop(), there will be a problem. How can I solve this problem?

void loop()
{


currentSensorReading = analogRead(sensorPin);
Serial.println(currentSensorReading );

    if(currentSensorReading is in range of certain values){
        rainbowCycle(20);
    }else{ turn LEDs off }
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

Thank you

But since both of these codes are inside the void loop(), there will be a problem.

Why?

How can I solve this problem?

The first step is to admit that you have a problem. No, wait. The first step is to define why you think there is a problem.

    delay(wait);

Aside from the obvious, that is. Do NOT use delay(). There are bazillions of threads discussing how not to.

I just paraphrased "at a same time" from your thread title and got some hits in the forum search at the upper right...
at the same time
It's a common problem, easily solved with millis().

Play with the "Blink Without Delay" example/demo in the IDE.

Cross-posted on arduino uno - Running both sensor and addressable LED strips at a same time? - Arduino Stack Exchange

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads/forums.