Need Help Please?!?!?!?!

Okay my arduino just arrived and i have spent the day playing with it, but i can't get something to work, i have four LED's conected 1x Red, 1x Blue, 2x White, i need the Red and blue to flash very quickly like a police light, and the white lights to flash alternativly like police car headlights, i can get both of these sequences to run separatly, but not together as i can;t figure out how to combine the two seperate bits of code.

Here is what i thought the code should look like, but it it make's errors and won;t upload to the arduino Duemilanove:

/* Police Undercover Car Light Sequence */

int red = 12;
int blu = 11;
int wht1 = 10;
int wht2 = 9;

// Red & Blue Lights
void setup()
{
  pinMode(blu, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(wht1, OUTPUT);
  pinMode(wht2, OUTPUT);
}

void loop()
{
digitalWrite(blu, HIGH);
delay(40);
digitalWrite(blu, LOW);
delay(40);
digitalWrite(blu, HIGH);
delay(40);
digitalWrite(blu, LOW);
delay(40);
digitalWrite(blu, HIGH);
delay(40);
digitalWrite(blu, LOW);
delay(40);
digitalWrite(blu, HIGH);
delay(40);
digitalWrite(blu, LOW);
delay(40);
digitalWrite(red, HIGH);
delay(40);
digitalWrite(red, LOW);
delay(40);
digitalWrite(red, HIGH);
delay(40);
digitalWrite(red, LOW);
delay(40);
digitalWrite(red, HIGH);
delay(40);
digitalWrite(red, LOW);
delay(40);
digitalWrite(red, HIGH);
delay(40);
digitalWrite(red, LOW);
delay(40);
}

void loop()
{
  digitalWrite(wht1, HIGH);
  delay(450);
  digitalWrite(wht1, LOW);
  digitalWrite(wht2, HIGH);
  delay(450);
  digitalWrite(wht2, LOW);
}

Please help i really want this to work!

Regards
Craig

you have two void loop functions. You only need, or more so, must only have one. Also, once you combine the two, you will need to tweak the code, otherwise what will happen is first your red and blue lights alternate (first blue, then red), and only once they stop flashing, the headlights alternate once, then they will stop and wait for the red and blue lights to flash through the sequence. I am guessing you want the two to occur parallel to each other, which is doable, but it wont happen if you just throw the contents of your second loop function into the end of the first one.

You need to find some lowest common denominator of the two sets of frequencies, and merge the loops.

Have a look at the "Blink without Delay" example sketch in your IDE.

You'll want to use a scheme like this instead of Delays to accomplish what you want.

sigh

Must be bored tonight.

Here.

Tested. Not optimized.. not best way, not the only way. Works 100% as described.

/* Police Undercover Car Light Sequence */

int red = 12;
int blu = 11;
int wht1 = 10;
int wht2 = 9;
int redblue_time = 40;
int whtwht_time = 450;
long last_redblue = 0;
long last_whtwht = 0;
long time_now;
bool red_state = HIGH;
bool blue_state = LOW;
bool wht1_state = HIGH;
bool wht2_state = LOW;

// Red & Blue Lights
void setup()
{
  pinMode(blu, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(wht1, OUTPUT);
  pinMode(wht2, OUTPUT);
}

void loop()
{
  time_now=millis();
  
  if ((time_now - last_redblue) > redblue_time)
  {
    if (red_state == HIGH)
    {
      red_state=LOW;
      blue_state=HIGH;
    }
    else
    {
      red_state=HIGH;
      blue_state=LOW;
    }
    digitalWrite(red,red_state);
    digitalWrite(blu,blue_state);
    last_redblue=time_now;
  }  

  if ((time_now - last_whtwht) > whtwht_time)
  {
    if (wht1_state == HIGH)
    {
      wht1_state=LOW;
      wht2_state=HIGH;
    }
    else
    {
      wht1_state=HIGH;
      wht2_state=LOW;
    }
    digitalWrite(wht1,wht1_state);
    digitalWrite(wht2,wht2_state);
    last_whtwht=time_now;
  }
  
}

Thats brilliant thanks guys, i now have another question, does anyone have an EAGLE librayr with the footprint for the Mini PCI Express Boards??

I need one for a project and can't fint one anywhere

thanks
Craig