sairfan1
Full Member level 1
- Joined
- Jun 12, 2010
- Messages
- 97
- Helped
- 4
- Reputation
- 8
- Reaction score
- 7
- Trophy points
- 1,288
- Location
- Regina, Canada
- Activity points
- 2,384
I'm trying to setup interrupt in arduino based environment using board ESP8266-01, based on help i found on different sites i wrote following code, but when i program my device it continuously shows interrupt message "Interrupt Ocurred: 1" on serial monitor, while same program running if i pull down the pin it shows "Interrupt Ocurred: 0" that means I'm using correct port and it state changes when i do it on hardware, I pulled up pin externally as well, I also tried same program on NodeMCU for different input pins
C:
#include <ESP8266WiFi.h>
const int InterruptPIN = 2;
volatile byte isrInterrupt_A = 0;
void ICACHE_RAM_ATTR IsrInterruptFunction();
void TestInterrupt();
void setup()
{
Serial.begin(115200);
pinMode(InterruptPIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(InterruptPIN), IsrInterruptFunction, FALLING);
Serial.print("Ready");
}
void loop()
{
if (isrInterrupt_A = 1) {
TestInterrupt();
delay(1000);
}
}
void IsrInterruptFunction() {
isrInterrupt_A = 1;
}
void TestInterrupt(){
Serial.println("Interrupt Ocurred: ");
Serial.println(digitalRead(InterruptPIN));
isrInterrupt_A = 0;
}