How do I change a delayby interrupt

Hii.....

I am working on density based traffic light control system and I wish that I get the density acknowledgement by using interrupt 0and 1 both, I want that whenever the interrupt 0 occurs the delay should be increased to say 5 secs and whenever the interrupt 1 occurs the same delay should be increased by 3 more secs. Please help me to get this done. here is the code on which I am working.

int G1G3 = A0;
int R1R3 = A1;
int G2G4 = A2;
int R2R4 = A3;

int Y1Y3 = A4;
int Y2Y4 = A5;

void setup()
{
Serial.begin(9600);
pinMode(G1G3,OUTPUT);
pinMode(R1R3,OUTPUT);
pinMode(G2G4,OUTPUT);
pinMode(R2R4,OUTPUT);
pinMode(Y1Y3,OUTPUT);
pinMode(Y2Y4,OUTPUT);

//first make all the lanes red for purpose of demo
digitalWrite(R1R3,HIGH);
digitalWrite(R2R4,HIGH);
delay(3000);

attachInterrupt(0,dense1,RISING);
attachInterrupt(1,dense2,RISING);
}

void loop()
{
//start with lane 1 and 3
digitalWrite(R1R3,LOW);

digitalWrite(G1G3,HIGH);

delay(3000); ///this delay is supposed to change when interrupt occurs

digitalWrite(G1G3,LOW);

digitalWrite(Y1Y3,HIGH);

delay(500);

digitalWrite(Y1Y3,LOW);

digitalWrite(R1R3,HIGH);

//DEMO of lane ! and # ends here

//start lane 2 and 4

digitalWrite(R2R4,LOW);

digitalWrite(G2G4,HIGH);

delay(3000);

digitalWrite(G2G4,LOW);

digitalWrite(Y2Y4,HIGH);

delay(500);

digitalWrite(Y2Y4,LOW);

digitalWrite(R2R4,HIGH);

//DEMO of lane 2 and 4 ends here
}

void dense1()
{
//start with lane 1 and 3
digitalWrite(R1R3,LOW);
digitalWrite(G1G3,HIGH);
delay(3000); ///the delay which is supposed to change on occurance of interrupt
digitalWrite(G1G3,LOW);
digitalWrite(Y1Y3,HIGH);
delay(500);
digitalWrite(Y1Y3,LOW);
digitalWrite(R1R3,HIGH);
//DEMO of lane ! and # ends here

//start lane 2 and 4
digitalWrite(R2R4,LOW);
digitalWrite(G2G4,HIGH);
delay(3000);
digitalWrite(G2G4,LOW);
digitalWrite(Y2Y4,HIGH);
delay(500);
digitalWrite(Y2Y4,LOW);
digitalWrite(R2R4,HIGH);
//DEMO of lane 2 and 4 ends here
}

You cannot use delay() in an ISR because it depends on interrupts and they are automatically disabled when the ISR is called. Use the ISRs to set a flag indicating that they have been triggered and maybe capture a timestamp. React to the flags in loop() and use the timestamps as a basis for actions based on time after the trigger but do not use delay() anywhere if you want to keep the system responsive. Consider using millis() for timing throughout the program

get rid of the delays and you wont need an interrupt
delays are evil

yea I was recently busted writing code that looked a lot like yours and was told I was being lazy to try using interrupt's to get around the delay issues.

these links helped me to get it right.

http://forum.arduino.cc/index.php?topic=223286.0

http://forum.arduino.cc/index.php?topic=223286.0

If you insist on using interrupts the code should be as simple as

void dense1() {
   interval = 5000;
}

and the code in loop() should use that value to do whatever

...R

thanks for the help....