fading LED at the same speed of a LED pattern

i really hope im not overstaying my welcome by asking so many questions, but ive been trying to work this out for about 40 minutes and keep getting worse and worse results.

basically what im doing is i have an LED pattern going, (LED, LED1, LED2, all the way to LED7), and then i have another LED (LED8) that is fading in and out. at the same time. Now i also have a pot that is controlling the speed of the pattern of LEDs, but i also want this same pot to control the speed of the fade of the LED. i want it so that after the void loop has completed once, it is as bright as its going to be, then as its competed again its completely faded off.

i tried to combine a code in the examples for a fading LED but it is not fading at all, and making LED6 and LED not blink in the pattern (it pauses right before it gets to those LEDs)

take a look at my code and see what you guys think…

/* this is a blinking pattern with a potentiometer to control speed. connect the pots first pin (left) to Gnd
second pin to a resistor then to analog pin 1, then the last pit to the 5V
*/


#define LED 13
#define LED1 12
#define LED2 11
#define LED3 10
#define LED4 9
#define LED5 8
#define LED6 7
#define LED7 6
#define LED8 5

int sensorPin = 0;    // select the input pin for the potentiometer
     
int sensorValue = 0;  // variable to store the value coming from the sensor



void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
  pinMode(LED7, OUTPUT);
  
  
}

void loop(){
  
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
     // sets the value (range from 0 to 255):
     analogWrite(LED8, fadeValue); 
     delay(sensorValue);  
     
     
     
   digitalWrite(LED, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED, LOW);

  digitalWrite(LED1, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED1, LOW);

  digitalWrite(LED2, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED2, LOW);

  digitalWrite(LED3, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED3, LOW);

  digitalWrite(LED4, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED4, LOW);

  digitalWrite(LED5, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED5, LOW);

  digitalWrite(LED6, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED6, LOW);
  
  
  
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) 
     // sets the value (range from 0 to 255):
     analogWrite(LED8, fadeValue);         
     // wait for 30 milliseconds to see the dimming effect    
        delay(sensorValue);  
                             

  digitalWrite(LED7, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED7, LOW);

  digitalWrite(LED6, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED6, LOW);

  digitalWrite(LED5, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED5, LOW);

  digitalWrite(LED4, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED4, LOW);

  digitalWrite(LED3, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED3, LOW);

  digitalWrite(LED2, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED2, LOW);

  digitalWrite(LED1, HIGH);
  sensorValue = analogRead(sensorPin);
  delay(sensorValue);
  digitalWrite(LED1, LOW);

  
  }
}

If you want the LEDs to fade, that is have the brightness increase or decrease, you need to have them connected to PWM pins, and write something other than HIGH or LOW to the LED pin(s).

If you want the LEDs to fade, that is have the brightness increase or decrease, you need to have them connected to PWM pins, and write something other than HIGH or LOW to the LED pin(s).

maybe im wrong but im pretty sure i did that.

LED8, which is the only light that will be fading, is connected to the PWM output, and doesnt have HIGH/LOW anywhere.

This is the code you have for fading the led down:

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
     // sets the value (range from 0 to 255):
     analogWrite(LED8, fadeValue);        
     // wait for 30 milliseconds to see the dimming effect    
        delay(sensorValue);

What this code is doing is calling analogWrite for the pin designated LED8 with the values 255, 250, 245, … 0, then calling delay.

If you put a { after the for statement, and a } after the delay statement, the LED will take time to fade down.

The same problem exists in the fade up code.

If you want to fade the led up while the other LEDs are being turned on, you need to look at the BlinkWithoutDelay example that uses millis() to determine when it is time to change the status of the LED pin(s).

alright, ill be able to work on it more this weekend.

will it be ok to bump this back up this weekend when ive have enough time to try this out and if it still doesnt work?

No need to bump anything. Just add your experiences, and any questions.