Hello guys,
I have problem with interrupt, I`ve read about interrupt from this, they said arduino yun have 5 ext interrupt: 3 (interrupt 0), 2 (interrupt 1), 0 (interrupt 2), 1 (interrupt 3) and 7 (interrupt 4).
I tried pin 3(interrupt 0) its work well, but when I tried another pin like pin 7(interrupt 4) it wont work. would you like to explain me why it can
t work properly like in pin 3?
here is my code, I used reed switch for counter..btw In my project future I use pin 2 and 3 as SCL and SDA for RTC.
#define RAIN_GAUGE_PIN 7 //from reedswitch
#define RAIN_GAUGE_INT 4
int rainCounter = 0;
float rain;
long lastDebounce0 = 0;
long debounceDelay = 500;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(RAIN_GAUGE_PIN, INPUT);
digitalWrite(RAIN_GAUGE_PIN, HIGH);
attachInterrupt(0, countRain, CHANGE);
}
void countRain(){
if( (millis() - lastDebounce0) > debounceDelay){
rainCounter++;
rain = (rainCounter * 0.2); // 1 pulse = 0.2794 mm
//Serial.println(rainCounter);
lastDebounce0 = millis();
}
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(rain);
delay(1000);
}