Advertisement
RuiViana

cli_sei.ino

Sep 27th, 2020 (edited)
1,459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. uint8_t interruptPin = 14;
  2. volatile byte interruptCounter = 0;
  3. int numberOfInterrupts = 0;
  4. bool  flagCred = false;
  5. //--------------------------------------------------------------------------
  6. void ICACHE_RAM_ATTR handleInterruptISR()
  7. {
  8.   flagCred = true;
  9. }
  10. //--------------------------------------------------------------------------
  11. void setup()
  12. {
  13.   Serial.begin(115200);
  14.   pinMode(interruptPin, INPUT_PULLUP);
  15.   attachInterrupt(interruptPin, handleInterruptISR, RISING);
  16. }
  17. //--------------------------------------------------------------------------
  18. void loop()
  19. {
  20.   if (flagCred == true)
  21.   {
  22.     if (digitalRead(interruptPin) == LOW)
  23.     {
  24.       delay(10);
  25.       if (digitalRead(interruptPin) == LOW)
  26.       {
  27.         flagCred = false;
  28.         interruptCounter++;
  29.         Serial.println(interruptCounter);
  30.       }
  31.     }
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement