Read sensor data repeatedly after specified time?
You store the time (millis()) of the last measurement. Then wait till 5ms have past since the last measurement. Do your measurement, and update the time.

Something like:

unsigned long lastMeasurement = millis();

void loop()
{
  while( (millis()-lastMeasurement)&lt;5 ){/* do nothing */}
  lastMeasurement = lastMeasurement + 5; //or use `lastMeasurement=millis();` depending on whether you want accuracy between measurement, or accuracy over time
  auto measurement = analogRead(A0);
}