Make LEDs Strobe & Fade, Trigered by Shock Sensor.

I have an arduino Uno, and have 2 LED strips connected to it (one with White LEDS and the other strip with Red LEDs).
I want the White LED strip to be on, then trigger a shock sensor to make the red LEDs strobe a few times, and then the White LEDs to go back on. So far I have been succesfull!! except of the FADING part.
I can get the shock sensor to trigger properly and the Strobe sequence too! but no matter what I do I cant get the Red LEDs to fade a couple times after they finish the strobing sequence… I have no idea what im doing wrong, I bet it’s something simple in writing the code propertly but I just cant figure it out spending countless hours, I would apresiate any help I could get!! thanks!

I just want the Red LEDs to fade after the strobe sequence ends

The white LEDs are on Pin 6, The Red LEDs are on Pin 9.

Here is my code:

int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

int buttonState = 0; // variable for reading the pushbutton status

void setup()
{
// initialize the LED pin as an output:
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(2, INPUT);
}

void loop()
{
buttonState = digitalRead(2); // read the state of the pushbutton value:
if (buttonState == LOW) // if it is, the buttonState is HIGH:
{
digitalWrite(6, LOW); // turn LED on:

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(21); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(15);

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(20); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(16);

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(19); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(17);

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(18); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(18);

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(17); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(19);

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(16); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(20);

digitalWrite(9, 255); // turn the LED on (HIGH is the voltage level)
delay(15); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(22);

//White LED ON

digitalWrite(6, HIGH); // turn LED on:

//---------THIS IS THE FADE FOR THE RED LED---------------- IT DOES NOT WORK & I DONT KNOW WHY, HELP!!!----

analogWrite(9, LOW);// set the brightness of pin 9:
brightness = brightness + fadeAmount;// change the brightness for next time through the loop:
if (brightness == 255 || brightness == 0) // reverse the direction of the fading at the ends of the fade:
{
fadeAmount = -fadeAmount ;
}
delay(30); // wait for 30 milliseconds to see the dimming effect

}
else
{
digitalWrite(9, LOW); // turn LED off:
}

}

Sequence 2.txt (11.5 KB)

digitalWrite(6, LOW);  // turn LED on:
:
:
digitalWrite(6, HIGH);  // turn LED on:

Which turns it on?

//---------THIS IS THE FADE FOR THE RED LED---------------- IT DOES NOT WORK & I DONT KNOW WHY, HELP!!!----
analogWrite(9, LOW);// set the brightness of pin 9:
:
:
digitalWrite(9, LOW); // turn LED off:

Where is the code that makes the pin go HIGH, via PWM, or by other means? I see some calculations for brightness & fadeamount, but there is no analogWrite with either value.

Nevermind I figured it out, by looking on the arduino sample tutorials Thanks!