Hi All,
So I've searched the forum and found this thread:
https://lowpowerlab.com/forum/moteino/multiple-interrupts/
Tom's code works great for using interrupts other than on INT0 and INT1 (because they seem to be disabled with that first line #define EI_NOTEXTERNAL)
However, I may have prematurely made a PCB where one of my buttons is connected to D3 - INT1 and the other is on D5. The D5 button works fine, but obviously the button on D3 doesn't work for interrupts.
Is there a way to disable the external interrupt in the enable interrupt library only on INT0 as to not interfere with the RFM69 library? Or am I out of luck and I have to cut traces on my PCB?
Thank you!
Quote from: doublec4 on April 10, 2018, 07:18:22 PM
Hi All,
So I've searched the forum and found this thread:
https://lowpowerlab.com/forum/moteino/multiple-interrupts/
Tom's code works great for using interrupts other than on INT0 and INT1 (because they seem to be disabled with that first line #define EI_NOTEXTERNAL)
However, I may have prematurely made a PCB where one of my buttons is connected to D3 - INT1 and the other is on D5. The D5 button works fine, but obviously the button on D3 doesn't work for interrupts.
Is there a way to disable the external interrupt in the enable interrupt library only on INT0 as to not interfere with the RFM69 library? Or am I out of luck and I have to cut traces on my PCB?
Thank you!
Did you try attaching interrupt to INT1? EI_NOTEXTERNAL will allow 'traditonal' attachInterrupt to this (and INT0) pins, it doesn't disable them - it can't because the radio still works on INT0.
Tom
Hi Tom,
I will try to use a traditional interrupt on pin 3 instead of using the enable interrupt library.
Here is the simple program I was using to test:
#define EI_NOTEXTERNAL // <===== THIS IS NECESSARY because the RFM69 library uses standard interrupt pin INT0, this tells the EnableInterrupt 'library' to not define INT0 or INT1
#include <EnableInterrupt.h>
#include <RFM69.h> // from https://github.com/LowPowerLab/RFM69
#include <SPI.h>
// Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
#define ARDUINOPIN 5
#define ANOTHERPIN 3
#define LED 4 // LED positive pin
void interruptFunction() {
digitalWrite(LED,HIGH);
}
void otherInterruptFunction() {
digitalWrite(LED,HIGH);
}
void setup() {
pinMode(LED,OUTPUT);
digitalWrite(LED,LOW);
pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE);
pinMode(ANOTHERPIN, INPUT_PULLUP);
enableInterrupt(ANOTHERPIN, otherInterruptFunction, CHANGE);
}
// In the loop we just display interruptCount. The value is updated by the interrupt routine.
void loop() {
delay(500);
digitalWrite(LED,LOW);
}
The LED lit up fine after pressing the button connected to D5. I will try a traditional interrupt on pin 3 and report back.
Thank you
As you suggested, a traditional attachInterrupt works perfectly for pin 3. Thank you!
For some reason my brain was stuck on using the enable interrupt to make it work.