Assignment: Iutput Devices

1. Iutput device -- APDS-9960 Sensor
2. APDS-9960 Sensor operation

First of all, thanks my friend Kun Liu for helping me to design the PCB,he is the expert in PCB designing.

The APDS-9960 device features advanced Gesture detection, Proximity detection, Digital Ambient Light Sense (ALS) and Color Sense (RGBC). The slim modular package, L 3.94 × W 2.36 × H 1.35 mm, incorporates an IR LED and factory calibrated LED driver for drop-in compatibility with existing footprints.

Applications

  • Gesture Detection
  • Color Sense
  • Ambient Light Sensing
  • Cell Phone Touch Screen Disable
  • Mechanical Switch Replacement
  • In Arduino, there is library for APDS-9960 sensor, the communcation mathod is I2C, so it is conventient for using.

    Datasheet of APDS-9960

    You can download the datasheeet file here.

    Pay more attention ,the pin1 is located in the top-right postion,no in the normal top-left position.The pin and the size of APDS-9960 is below:

    Designing schematic and PCB

    I design the APDS-9960 using Eagle. You can download the design file here. . Becasue the pin of APDS-9960 is too small, so I enlarge the pad in width.

    The schematic design is the following.

    The pcb border design is the following.

    Milling PCB

    I use the Fabmodules.org to generate the milling file, and use MDX-40 milling machine to mill the board.

    Since the chip's packaging is too small, the pads are joined together during milling, so I changed the size of the pad by Photoshop before milling. The picture is as follows.

    You can download the design file here.

    Soldering the PCB


    Home

    Pay more attention on the voltage is 3.3V. Because my 328P board can not provide 3.3V, so I connect the sensor to Arduino sheild which can provide 3.3V power.

    Download and install the Arduino library

    You can download the Arduino library here.

    Install library to the Arduino. Open the example program provide in the library, according to the sequence: File->Examples->SparkFun APD9960 RGB and Gesture Sensor->Gesture Test

    
    
    	#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;
    
    	void setup() {
    
    	  // Set interrupt pin as input
    	  pinMode(APDS9960_INT, INPUT);
    
    	  // 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!"));
    	  }
    	}
    
    	void loop() {
    	  if( isr_flag == 1 ) {
    		detachInterrupt(0);
    		handleGesture();
    		isr_flag = 0;
    		attachInterrupt(0, interruptRoutine, FALLING);
    	  }
    	}
    
    	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");
    		}
    	  }
    	}
    


    Connection

    Connect the snesor to the Arduino UNO board.

    APDS-9960 Sensor operation

    Uploading the program, open the Serial monitor window, then move you hand on the APDS-9960 Sensor . When you move hand from left to right, "Left" will be displayed in the Serial monitor window. The operation result is the following.

    At first, uploading the program , the APDS-9960 Sensor doesn't work, the problem is soldering point between APDS-9960 Sensor and board does not connect well, after re-solder ,the sensor works normally.

    Home