control pins independently without delay()

Hello Korman,

Here is some code I cobbled together. Eventually I would like to have as many pins being controlled as the arduino will allow (duemillanove, mega...). Currently the code seems to just toggle 2 pins, where as I would like to be able to pick a time when the pin is "on" and then turns "off". I created a function called "sequence" that is called when the switch goes HIGH. This is probably bad code, but it is a begining. Any help and insight would be appreciated.

int buttonPin = 2;
int buttonState = 0;

int value = 0;
int event1 = 9;
int event2 = 10;
int value1=0, value2=0;
long time1, time2;

void setup() {

pinMode(buttonPin, INPUT);

pinMode(event1, OUTPUT);
pinMode(event2, OUTPUT);

time1=millis(); // set time as now
time2=millis();

}
void sequence(){
if(time1 > millis()) {
digitalWrite(event1, value1); // sets the LED on
if(value1 ==0) value1 =1; else value1 = 0; // toggle led value
event1= millis() +1000; // set next time you want to do anything
}

if(event2>millis()) {
digitalWrite(event2, value2); // sets the LED on
if(value2 ==0) value2=1; else value2=0; // toggle led value
event2= millis() +700; // set next time you want to do anything this is faster
}
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
//run the milli() multipe pin function
void sequence();
}}