EL wire

Hey guys I have this EL wire and basically what I’m doing is when the someone passes the IR sensor the EL fades on stays on for 3 seconds then just goes off (it does not fade out). My problem is that I can’t figure out after having it fade on how i get it to stay on for the 3 seconds then go off.

Here is my code

int IRpin = 0; // select the input pin for the potentiometer
int fanPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
int ledPin = 9; // LED connected to digital pin 9

#define TRIG_VAL 500 //

void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(IRpin);

if (sensorValue > TRIG_VAL) {
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);

}

// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(500);
}
while (analogRead(IRpin) > TRIG_VAL); // now wait for the object to leave before allowing a repeat performance
}
}

Putting each { on it's own line, and using Tools + Auto format... would make the structure of your program more obvious.

Removing the excessive white space would not hurt, either.

My problem is that I can't figure out after having it fade on how i get it to stay on for the 3 seconds then go off.

You have a for loop that fades up. You have a for loop that fades down. You can't figure out that delay(3000) in between will keep the light on?

// wait for 30 milliseconds to see the dimming effect   
    delay(100);

You may want to line up your comments with your code.