I am using APDS-9960 Gesture sensor with arduino DUE using SparkFun library but it does not seems to work.
I guess I do not need any logic converter here between sensor and due because DUE operates on 3.3V so does the gesture sensor.
This is the sensor I am using "RGB and Gesture Sensor - APDS-9960 - Proximity Detection Sensor Module"
Below is the code I am using.
#include<Wire.h>
#include<SparkFun_APDS9960.h>
#define gesture_interrupt 2
SparkFun_APDS9960 apds9960 = SparkFun_APDS9960();
volatile int interrupt_flag = 0;
void setup()
{
pinMode(gesture_interrupt, INPUT);
Serial.begin(9600);
attachInterrupt(0, interruptRoutine, FALLING);
if(apds9960.init())
{
Serial.println("FOUND APDS-9960 Module!");
}
else
{
Serial.println("Can't find APDS-9960 MODULE");
}
if ( apds9960.enableGestureSensor(true))
{
Serial.println("Gesture sensor is enabled!");
}
else
{
Serial.println("Can't start the Gesture sensor...");
}
}
void loop()
{
if(interrupt_flag == 1)
{
detachInterrupt(0);
handleGesture();
interrupt_flag = 0;
attachInterrupt(0, interruptRoutine, FALLING);
}
}
void interruptRoutine()
{
interrupt_flag = 1;
}
void handleGesture()
{
if(apds9960.isGestureAvailable())
{
switch(apds9960.readGesture())
{
case DIR_UP:
Serial.println("UP");
delay(500);
break;
case DIR_DOWN:
Serial.println("DOWN");
delay(500);
break;
case DIR_LEFT:
Serial.println("LEFT");
delay(500);
break;
case DIR_RIGHT:
Serial.println("RIGHT");
delay(500);
break;
case DIR_NEAR:
Serial.println("NEAR");
delay(500);
break;
case DIR_FAR:
Serial.println("FAR");
delay(500);
break;
}
}
}
SDA pin 20
SCL pin 21
interrupt pin 2
VCC 3.3V and GND from DUE board
Let me know if I am missing anything in the code or in the connection?
Thanks in advance.