11
12 // Initialize Serial port
13 Serial.begin(9600);
14 Serial.println();
15 Serial.println(F("--------------------------------"));
16 Serial.println(F("APDS-9960 - GestureTest"));
17 Serial.println(F("--------------------------------"));
18
19 // Initialize interrupt service routine
20 attachInterrupt(0, interruptRoutine, FALLING);
21
22 // Initialize APDS-9960 (configure I2C and initial values)
23 if ( apds.init() ) {
24 Serial.println(F("APDS-9960 initialization complete"));
25 } else {
26 Serial.println(F("Something went wrong during APDS-9960 init!"));
27 }
28
29 // Start running the APDS-9960 gesture sensor engine
30 if ( apds.enableGestureSensor(true) ) {
31 Serial.println(F("Gesture sensor is now running"));
32 } else {
33 Serial.println(F("Something went wrong during gesture sensor init!"));
34 }
35 }
36
37 void loop() {
38 if( isr_flag == 1 ) {
39 handleGesture();
40 if(digitalRead(APDS9960_INT) == 0){
41 apds.init();
42 apds.enableGestureSensor(true);
43 }
44