Interrupt problem with Pro-mini


The following code is supposed to lit 2 leds (with a delay between them) whenever button is pressed. And also when first booted. When booted, it does it perfectly.

However, when button is pressed, both leds flash twice and nothing else happened.

I have tried "Rising" instead of "High" with no difference.

Debounce is important as the button is very noisy.

Appreciate any help.

//Arduino pro/mini running

long debouncing_time = 15; //Debouncing Time in Milliseconds
volatile unsigned long last_micros;
#define poweruppin 3
#define playbackpin 4
const byte interruptPin = 2;
volatile byte state = LOW;
long intervalogle = 10000; // interval at which to do something (milliseconds) 1 minute = 60,000
unsigned long previousMillisogle = 0;
long intervalaksam = 5000; 
unsigned long previousMillisaksam = 0;
int firstrun = 1;
void setup() 
pinMode(poweruppin, INPUT);
pinMode(playbackpin, INPUT);
pinMode(interruptPin, INPUT_PULLUP);
digitalWrite(poweruppin, LOW); //OFF by default
digitalWrite(playbackpin, LOW); 
attachInterrupt(digitalPinToInterrupt(interruptPin), debounceInterrupt, HIGH);

void loop() 

if (firstrun == 1)
              Serial.println("First run baby...");
        unsigned long currentMillisogle = millis();
        if(currentMillisogle - previousMillisogle >  intervalogle)
             previousMillisogle = currentMillisogle;  

void showtime()
  firstrun = 0;
  Serial.println("Power up...");
  digitalWrite(poweruppin, HIGH);
  digitalWrite(playbackpin, HIGH);
  delay(30000); //wait for playback to complete
  digitalWrite(poweruppin, LOW);
  digitalWrite(playbackpin, LOW);
  Serial.println("All Off...");

void debounceInterrupt() {
  if((long)(micros() - last_micros) >= debouncing_time * 1000) {
    last_micros = micros();

void Interrupt() {
  Serial.println("interrupt happened...");

I notice that you are printing inside a function called from an ISR.

Interrupts are disabled when an ISR is active Serial printing uses interrupts

Can you see that there might be a problem ?

I disabled it, with no avail.

Why are you using an interrupt to detect a button press? Humans are very slow and polling should be fine.


As I mentioned, button is noisy. But the though crossed my mind. I'll try it now.

Yes. No interrupt is better.

Arduino warns against micros in interrupt. I'll research that as well.

Thank you all for your input.


When you in interrupt - all other interrupts are disabled and millis is not "ticking" as well. And delay() doesn't work. You can enable interrupt using sei() at the beginning of interrupt(). But you whole design is not good.

UPD. It's absolutely valid approach to serve buttons by interrupt, but design should be completely different.

alesam: You can enable interrupt using sei() at the beginning of interrupt().

NOT a good idea for a beginner :)