Fade in and out an LED sketch inside a larger program slows the program down

I wrote a sketch for a self leveling sissor table with a calibration button. The button is one that has a nice red ring around it that is lit by an LED. I got my hands on some code that will fade in and fade out the led to make it look cool ( like on a mac computer). When I input that LED code into my sketch it slows the entire program down to the dimming speed.

How can I separate the speeds/sketches so that they can both operate off of an arduino uno?

I know I have to put the LED in the set up and so on…

The following is my table sketch:

int groundpin = 18;
int powerpin = 19;
int xpin = 3;
int ypin = 2;
int zpin = 1;

#define BUTTON 7 
                
int val = 0;    
              
int relay1 = 11;
int relay2 = 10;
long y = 0;
long a = 0;

void setup(){
  
  Serial.begin(9600);
  pinMode(BUTTON, INPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
}

void loop()
{
  a = analogRead (ypin);
  
  Serial.println (analogRead(ypin));
 
  delay(10);
  
  val = digitalRead(BUTTON); 
  
 if (val == HIGH) { 
     
          Serial.print("y = ");
           
          y = analogRead(ypin); 
            
          //delay (25);
 }
    
 if (a > (y + 6)) {
   
         digitalWrite(relay1, HIGH);
   
         Serial.print (y);
    
         Serial.println("---The Table Is Off Level--- 1"); 
  
         delay (500);
  } else {
    
  digitalWrite(relay1, LOW);
  } 

  if (a < (y - 6)) {
    
         digitalWrite(relay2, HIGH);
    
         Serial.print (y);
    
         Serial.println("---The Table Is Off Level--- 2"); 
    
         delay (500);
         
  } else  { 
    
  digitalWrite(relay2, LOW);
  
    }
 }

Here is the dimming code:

#define LED 9
int i = 0;

void setup(){
  pinMode(LED, OUTPUT);
}
void loop() {
  
  for (i = 0; i < 255; i++) {
  analogWrite(LED, i);
  delay(15);
}

for (i = 255; i > 0; i--) {
  analogWrite(LED, i);
  delay(15);
}
}

Any suggestions would be appreciated!

Rewrite your code to not use delay(). Read up on the BlinkWithoutDelay example in the playground.

http://wikibox.stanford.edu/12-13/index.php/Assignments/BasicArduinoMultiTaskTutorial