Sqeuences

Hi there,

i'm trying to figure out a random function starting different sequences. The 'sequences' are simple blinking of leds. I'm using a Duemilanove.

here are 2 different sequences i wrote.

// sequence 1 and 2
void loop() {

  //led1
  digitalWrite(ledPin1, HIGH);
  delay(100);
  digitalWrite(ledPin1, LOW);    
  delay(80);
  digitalWrite(ledPin1, HIGH);
  delay(100);
  digitalWrite(ledPin1, LOW);    
  delay(80);
  digitalWrite(ledPin1, HIGH);
  delay(150);
  delay(500);

  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=8) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin1, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);      
  }
  digitalWrite(ledPin1, LOW);    
  delay(3000);

  //led2
  digitalWrite(ledPin2, HIGH);
  delay(100);
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    analogWrite(ledPin2, fadeValue);         
    delay(20);      
  }
  delay(200);

  digitalWrite(ledPin2, HIGH);
  delay(70);
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    analogWrite(ledPin2, fadeValue);         
    delay(45);      
  }
  delay(2300);
  digitalWrite(ledPin2, HIGH);
  delay(120);

  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=10) { 
    analogWrite(ledPin2, fadeValue);         
    delay(10);      
  }
  digitalWrite(ledPin2, LOW);    
  delay(4000);
}

how do i create different 'Presets' and call them up with the random function? or Do i work with classes?

what would be the best way to work around this?

best

Put your sequences into sub-routines and call them based on the return value of the random(2) function.