Here is a generic BWD TIMER example that you might find helpful with learning millis() timing.
//********************************************************************************
// Version YY/MM/DD Description
// 1.00 21/06/12 Running sketch
//
#define LEDon HIGH
#define LEDoff LOW
#define CLOSED LOW
#define OPENED HIGH
#define PRESSED LOW
#define RELEASED HIGH
#define ENABLED true
#define DISABLED false
//***************************************************************
bool LEDflag = DISABLED;
const byte heartbeatLED = 13; //[PIN 13]---[220R]---[A->|-K]---GND
const byte testLED = 12;
const byte mySwitch = 2; //+5V---[50k Pullup]---Pin2---[mySwitch]---GND
byte lastMySwitchState = OPENED;
//timing stuff
unsigned long heartbeatMillis;
unsigned long switchMillis;
unsigned long ledMillis;
const unsigned long ledInterval = 5000ul; //5 seconds
//***************************************************************
void setup()
{
pinMode(heartbeatLED, OUTPUT);
pinMode(testLED, OUTPUT);
pinMode(mySwitch, INPUT_PULLUP);
} //END of setup()
//***************************************************************
void loop()
{
//************************************* h e a r t b e a t T I M E R
//to see if the sketch is blocking,
//is it time to toggle the LED ?
if (millis() - heartbeatMillis >= 500)
{
//restart the TIMER
heartbeatMillis = millis();
//toggle the LED
digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
}
//************************************* c h e c k S w i t c h T I M E R
//is it time to read the switches ?
if (millis() - switchMillis >= 50)
{
//restart the TIMER
switchMillis = millis();
//go read the switches
checkSwitches();
}
//************************************* t e s t L E D T I M E R
//if enabled, has the testLED TIMER expired ?
if (LEDflag == ENABLED && millis() - ledMillis >= ledInterval)
{
LEDflag = DISABLED;
digitalWrite(testLED, LEDoff);
}
//*************************************
//other non blocking code goes here
//*************************************
} //END of loop()
//********************************************************************************
void checkSwitches()
{
//********************************************* m y S w i t c h
//runSwitch code
byte currentState = digitalRead(mySwitch);
//**********************
//was there a change in state ?
if (lastMySwitchState != currentState)
{
//update to the new state
lastMySwitchState = currentState;
//********************** C L O S E D
//if LED TIMER is disabled, is this switch closed ?
if (LEDflag == DISABLED && currentState == CLOSED)
{
//enable the LED TIMER
LEDflag = ENABLED;
//start the LED TIMER
ledMillis = millis();
digitalWrite(testLED, LEDon);
}
} //END of mySwitch code
//********************************************* o t h e r S w i t c h e s
//next switch code
//*********************************************
} //END of checkSwitches()
//********************************************************************************