#include "Cloud_PLC.h" const int digitalPin = IN4; // the value can be assigned as your preference IN1, IN2, IN3, IN4. volatile int count = 0; //initialize count as 0 int interval = 250; //debounce time long button_time = 0; long LAST_COUNT = 0; void IRAM_ATTR Ext_INT4_ISR() { // function for button_time = millis(); // Assign millis() to button_time (millis() Returns the number of milliseconds since the device began running the current program) if (button_time - LAST_COUNT > interval) { if (digitalRead(digitalPin) == HIGH) { LAST_COUNT = button_time; count++; Serial.println(count); } } } void setup() { Cloud_PLC_initialisation(); // Config digital pins IN1,IN2,IN3 and IN4 as INPUT Serial.begin(9600); attachInterrupt(digitalPinToInterrupt(digitalPin), Ext_INT4_ISR, RISING); } void loop() { // put your main code here, to run repeatedly: } }