APDS-9960 Int Pin stuck Low

Hey everyone.

I've been playing around with the Sparkfun Gesture Sensor, but I seem to run into an issue. There are certain cases where after the sensor reads a gesture (INT Pin falling from ~3V to 0V), the INT pin stays at 0V, which prevents it from reading anymore gestures. I've tried unattaching and reattaching the pin after each interrupt, but this does seem to work either. Anyone one have an idea of why the INT pin stays stuck at low?

/****************************************************************
GestureTest.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
May 30, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor

Tests the gesture sensing abilities of the APDS-9960. Configures
APDS-9960 over I2C and waits for gesture events. Calculates the
direction of the swipe (up, down, left, right) and displays it
on a serial console. 

To perform a NEAR gesture, hold your hand
far above the sensor and move it close to the sensor (within 2
inches). Hold your hand there for at least 1 second and move it
away.

To perform a FAR gesture, hold your hand within 2 inches of the
sensor for at least 1 second and then move it above (out of
range) of the sensor.

Hardware Connections:

IMPORTANT: The APDS-9960 can only accept 3.3V!
 
 Arduino Pin  APDS-9960 Board  Function
 
 3.3V         VCC              Power
 GND          GND              Ground
 A4           SDA              I2C Data
 A5           SCL              I2C Clock
 2            INT              Interrupt

Resources:
Include Wire.h and SparkFun_APDS-9960.h

Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V

This code is beerware; if you see me (or any other SparkFun 
employee) at the local, and you've found our code helpful, please
buy us a round!

Distributed as-is; no warranty is given.
****************************************************************/

#include <Wire.h>
#include <SparkFun_APDS9960.h>

// Pins
#define APDS9960_INT    2 // Needs to be an interrupt pin

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
char state;
int i = 0;
void setup() {

  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);
  pinMode(9, OUTPUT);
  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
  
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
  
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }
  
  
  state = 'R';
}

void loop() {
  /*
  //Test 1  Case Statement
  switch (state){
    case 'R':
      if( isr_flag == 1 ) {
        detachInterrupt(0);
        handleGesture();
        digitalWrite(9, HIGH);
        delay(5000);
        isr_flag = 0;
        Serial.println("STATE R");
        state= 'X';
        attachInterrupt(0, interruptRoutine, FALLING);
        break;
      }
      //Serial.println("delay");
  
      
      digitalWrite(9, LOW);  
    
    case 'X':
      if (isr_flag == 1) {
        
        detachInterrupt(0);
        handleGesture();
        digitalWrite(9, HIGH);
        delay(5000);
        Serial.println("STATE X");
        isr_flag=0;
        state = 'R';
        attachInterrupt(0, interruptRoutine, FALLING);
         
        break;     
      }
      attachInterrupt(0, interruptRoutine, FALLING);
      digitalWrite(9, LOW);
  } 
  
  */
//TEST 2  
  Serial.println("Loop Again");  
  Serial.println(i);
  //delay(1000);
  if (isr_flag == 1){
    detachInterrupt(0);
    delay(1000);
    attachInterrupt(0, interruptRoutine, FALLING);
    digitalWrite(9,HIGH);
    i -= 1;
    digitalWrite(9,LOW);
    isr_flag=0;
  }
  i += 1; 
  
  
}

void interruptRoutine() {
  isr_flag = 1;
}

void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        break;
      case DIR_NEAR:
        Serial.println("NEAR");
        break;
      case DIR_FAR:
        Serial.println("FAR");
        break;
      default:
        Serial.println("NONE");
    }
  }
}

looks like the sensor need to be told that the interrupt is been taken care of.. (just my guess)

Hi i'm Lucio ,
i try the sensor APDS9960 and i'm not so happy aboute the resoult of the gesture .
I try to modify the SW in the way to don't use the interrupt , but if the sensore detect an object at the right distance ( in a range ) jump to the void of the gesture .
Mine big point is that not all the time works .

[code]


#include <Wire.h>
#include <SparkFun_APDS9960.h>
#define DS1307_I2C_ADDRESS 0x68
// Variabili globali
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint8_t proximity_data = 0;
uint16_t ambient_light = 0;
uint16_t red_light = 0;
uint16_t green_light = 0;
uint16_t blue_light = 0;
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
int ledPind=12;
int ledPins=13;
int luminosita=0;

  byte decToBcd(byte val)                                                      // Conversione normali numeri decimali in binario decimale
  {
    return ( (val/10*16) + (val%10) );
  }
  
  byte bcdToDec(byte val)                                                      // Conversione decimale binario a normali numeri decimali
  {
    return ( (val/16*10) + (val%16) );
  }
 
  
  void getDateDs1307(byte *second,                                             // Ottiene la data e l'ora dal DS1307 
  byte *minute,
  byte *hour,
  byte *dayOfWeek,
  byte *dayOfMonth,
  byte *month,
  byte *year)
  {
    
    Wire.beginTransmission(DS1307_I2C_ADDRESS);                                 // Ripristina il puntatore del registro 
    Wire.write(0);
    Wire.endTransmission();
    Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
    
    *second = bcdToDec(Wire.read() & 0x7f);                                     // Alcuni di questi sono necessari, perché le maschere di alcuni bit sono bit di controllo 
    *minute = bcdToDec(Wire.read());
    *hour = bcdToDec(Wire.read() & 0x3f);                                       // Occorre modificare questo se 12 ore am/pm
    *dayOfWeek = bcdToDec(Wire.read());
    *dayOfMonth = bcdToDec(Wire.read());
    *month = bcdToDec(Wire.read());
    *year = bcdToDec(Wire.read());
  }
void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(ledPind, OUTPUT);
  pinMode(ledPins, OUTPUT);
  // Initialize Serial port
  Serial.begin(9600);
  
  
  if ( apds.init() ) {                                                        // Inizializziamo APDS-9960 
    
  } else {
    errore();
  }
  
  
  if (( !apds.setProximityGain(PGAIN_2X) ) || ( !apds.setGestureGain(GGAIN_1X) )){                              // Regoliamo il gain del sensore prossimità e gesti
      errore();
  }
  
  
  if (( apds.enableProximitySensor(false) ) && ( apds.enableGestureSensor(true) )&& ( apds.enableLightSensor(false) )){                              // Start del sensore di prossimità e gestualità
      }
      else {
     errore();
  }
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
    Wire.begin();
  
  delay(1000);                                                                                      // diamo tempo che finisce le sue cose
}

void loop() {
    if (( !apds.readProximity(proximity_data) ||                            // leggiamo i valori della distanza, della luce e dei colori
            !apds.readAmbientLight(ambient_light) ||                          
              !apds.readRedLight(red_light) ||
                !apds.readGreenLight(green_light) ||
                  !apds.readBlueLight(blue_light) )) {                            
                    
  } 
    else {
      if((proximity_data<220)&&(proximity_data>170)){
      Serial.print("Proximity: ");
       Serial.println(proximity_data);
        Serial.print("Ambient: ");
         Serial.print(ambient_light);
          Serial.print(" Red: ");
           Serial.print(red_light);
            Serial.print(" Green: ");
             Serial.print(green_light);
              Serial.print(" Blue: ");
               Serial.println(blue_light);
               }
    
    luminosita=map(ambient_light,0,5000,0,255);                             //regolo la luminosità dei led in base alla luminosità ambiente  
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
     getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
      
    
      if((hour>=22 || hour<7 )&&(dayOfWeek!=7))
      {
      if (ambient_light>190 )
        { 
      arrabbiato(); 
        }
      else
        {
        dormi();
        }
      }
      else
      {
            if(proximity_data>220){
            arrabbiato();
              }
    
            else if(proximity_data<170){
            normale();
              }
            else{
            attcomando();
            delay(1000);
            dormi();
            handleGesture();
              }
     }
  }
}
void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        for (int i=0; i >20; i++){
         attcomando();
          delay(1000);
           normale();
            delay(1000);
            } 
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        for (int i=0; i >20; i++){
         attcomando();
          delay(1000);
           arrabbiato();
            delay(1000);
            }
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        for (int i=0; i >20; i++){
         analogWrite(bluePin, luminosita);
          digitalWrite(ledPind,LOW);
           digitalWrite(ledPins,HIGH);
            delay(1000);
             digitalWrite(ledPins,LOW);
              delay(1000);
               } 
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        for (int i=0; i >20; i++){
         analogWrite(bluePin, luminosita);
          digitalWrite(ledPind,HIGH);
           digitalWrite(ledPins,LOW);
            delay(1000);
             digitalWrite(ledPind,LOW);
              delay(1000);
              } 
        break;
      case DIR_NEAR:
        Serial.println("NEAR");
          for (int i=0; i >20; i++){
           analogWrite(redPin, luminosita);
            digitalWrite(ledPind,HIGH);
             digitalWrite(ledPins,LOW);
              delay(1000);
               digitalWrite(ledPind,LOW);
                digitalWrite(ledPins,HIGH);
                 delay(1000);
                 }
        break;
      case DIR_FAR:
        Serial.println("FAR");
         for (int i=0; i >20; i++){
          analogWrite(bluePin, luminosita);
            digitalWrite(ledPind,HIGH);
             digitalWrite(ledPins,LOW);
              delay(1000);
               digitalWrite(ledPind,LOW);
                digitalWrite(ledPins,HIGH);
                 delay(1000);
                 }
        break;
      default:
        Serial.println("NONE");
        
    }
  }
}
  void arrabbiato(){
    analogWrite(redPin, luminosita);
     analogWrite(greenPin, 0);
      analogWrite(bluePin, 0);
       digitalWrite(ledPind,HIGH);
        digitalWrite(ledPins,HIGH);
        }
  void normale(){
    analogWrite(redPin, 0);
     analogWrite(greenPin, 0);
      analogWrite(bluePin, luminosita);
       digitalWrite(ledPind,HIGH);
        digitalWrite(ledPins,HIGH);    
        }
  void attcomando(){
    analogWrite(redPin, 0);
     analogWrite(greenPin, luminosita);
      analogWrite(bluePin, 0);
       digitalWrite(ledPind,HIGH);
        digitalWrite(ledPins,HIGH);
         }
  void dormi(){
     digitalWrite(ledPind,LOW);
      digitalWrite(ledPins,LOW);    
      }
  void errore(){
    arrabbiato();
    delay(500);
    dormi();
    delay(500);
    errore();
    }

[/code]

Any idea ?
Thank

The OP has asked this question on another forum, and gotten an answer (at least think it's the OP- exact same question):
sparkfun

I seem unable to find a solution to this and even at that sparkfun link I find nothing. I have my code attaching an interrupt to its interrupt pin with a FALLING edge. However when something is placed in front of the sensor and stays there the signal stays low and my code never exits the ISR. Thus if someone sits too close to the unit all code stops functioning... I've tried detaching the interrupt inside the ISR to no avail.