Working on getting capacitive touch sensor (CAP-1188) to register single and multiple clicks

Hi there.

I am using a CAP-1188 break out board (https://learn.adafruit.com/adafruit-cap1188-breakout/overview) with the Particle library. It seems to work fine. The sample code uses a loop to get the value of whichever pin is touched and prints the value constantly.

What I am looking for is a way to monitor the touch inputs. Basically an interrupt would work, but I’m not sure how to code that without an “interrupt pin”. The dev board is connected through pins D0 and D1 on the Photon through I2C.

Ultimately I want a variable that can be set to and print out once whenever a sensor is touched and also be able to register taps in sequential order. By that I mean I need to be able to register single, double, and triple taps (within a reasonable time frame, say 300ms between, otherwise they do not register as multiple taps). So I will need some way to monitor the 1,2, or 3 number of taps the user will do as well. Each of those three instances will then run some code.

Here’s what the example code looks like included in the library:

    // This #include statement was automatically added by the Particle IDE.
#include "Adafruit_CAP1188.h"

//For SDA in Photon use pin D0
//For SCK in Photon use pin D1
// VIN works with both 3.3V and 5V

Adafruit_CAP1188 cap = Adafruit_CAP1188();

void setup() {

  Serial.begin(19200);
  cap.begin();

  //we set our level of sensitivity
  //we pass values from 1 to 7
  cap.setSensitivity(2);
  
    cap.writeRegister(0x44, 0x41);  // 0x44 default 0x40 use 0x41  -- Set interrupt on press but not release
  cap.writeRegister(0x28, 0x00);  // 0x28 default 0xFF use 0x00  -- Turn off interrupt repeat on button hold


}

void loop() {
  int8_t touchValue = cap.touched();


  //cap.touchedAnalog(1) will call second electrode analog values
//  for (byte i = 0; i < 8; i++){
 //   int8_t analogValues = cap.touchedAnalog(i);
 //   Serial.print(i);Serial.print(" : ");Serial.print(analogValues);Serial.print("\t");
//  }


  Serial.println(touchValue);
  
}

Thank you for any advice!

There is an IRQ pin on the Adafruit breakout, or are you using another one?