Wednesday, 18 September 2013

Interruption for Button and Button Press for Longer then 3 Secs

Interruption for Button and Button Press for Longer then 3 Secs

In my project, I have three buttons where each triggers a function.
This function have to do two things, one action when the button is pressed
(actually working), but I want to add a second functionality, in which if
the button is pressed for more then 3 seconds, it do something, like
calling a function.
So far, i'm initializing the interruption:
attachInterrupt(0, footOne, Falling);
and the function is:
void footOne(){
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// Debounce
if (interrupt_time - last_interrupt_time > 200){
//Do things
if(debug==1){Serial.println("Button 1 pressed!");}
}
last_interrupt_time = interrupt_time;
}
Now I want to know how I can change the function to add the possibility if
the button is pressed for longer then 3 seconds...
Remembering that this function is called from the interrupts.
Thank you!

No comments:

Post a Comment