LowPowerLab Forum

Hardware support => Moteino => Topic started by: K1JOS on August 30, 2014, 04:29:12 PM

Title: Which External Interrupt to Use on MegaMoteino {SOLVED}
Post by: K1JOS on August 30, 2014, 04:29:12 PM
My application was successfully using INT1 (D3) on the Moteino  but I have moved everything to the MegaMoteino.  The only available interrupt on the MegaMot is one of the two pins used for the hardware SER1.

Do I need to do anything special in code first to deactivate the SER1 function or do I just call the same code as before:
Here are the relevant snippets:


void setup(){
attachInterrupt(1, debounceInterrupt, FALLING);
digitalWrite(11,INPUT_PULLUP);  // on Mega using Pin 11 INT1
}

void Loop(){
//do stuff here
}

void debounceInterrupt(){
  if(((long)(micros() - last_micros) >= debouncing_time * 1000)) {
    last_micros = micros();
    interrupt_flag = true;  //set flag but make sure to reset it later - it is checked my void Loop() routines
    } 
}
 

I tried the identical Moteino button debounce interrupt code on the Mega without any changes and it does not work any more.

Title: Re: Which External Interrupt to Use on MegaMoteino
Post by: Felix on August 30, 2014, 09:14:23 PM
The RFM uses interrupt 2 on the MEGA and there's nothing special about it. The same code should work just fine as long as you setup the interrupt the same way. So INT0 and 1 are on the SER1 pins.