Giter Club home page Giter Club logo

sparkfun_apds-9960_sensor_arduino_library's Introduction

SparkFun APDS9960 RGB and Gesture Sensor Arduino Library

Avago APDS-9960 Breakout Board - SEN-12787

Avago APDS-9960 Breakout Board (SEN-12787)

Getting Started

  • Download the Git repository as a ZIP ("Download ZIP" button)
  • Unzip
  • Copy the entire library directory (APDS-9960_RGB_and_Gesture_Sensor_Arduino_Library ) to <Arduino installation directory>/libraries
  • Open the Arduino program
  • Select File -> Examples -> SparkFun_APDS9960 -> GestureTest
  • Plug in your Arduino and APDS-9960 with the following connections

-OR-

  • Use the library manager
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
2 INT Interrupt
  • Go to Tools -> Board and select your Arduino board
  • Go to Tools -> Serial Port and select the COM port of your Arduino board
  • Click "Upload"
  • Go to Tools -> Serial Monitor
  • Ensure the baud rate is set at 9600 baud
  • Swipe your hand over the sensor in various directions!

Repository Contents

  • /examples - Example sketches for the library (.ino). Run these from the Arduino IDE.
  • /src - Source files for the library (.cpp, .h).
  • library.properties - General library properties for the Arduino package manager.

Documentation

Products that use this Library

Version History

  • V_1.4.1 - Removing blank files, updating library.properties file.
  • V_1.4.0 - Updated to new library structure
  • V_1.3.0 - Implemented disableProximitySensor(). Thanks to jmg5150 for catching that!
  • V_1.2.0 - Added pinMode line to GestureTest demo to fix interrupt bug with some Arduinos
  • V_1.1.0 - Updated GestureTest demo to not freeze with fast swipes
  • V_1.0.0: Initial release
  • Ambient and RGB light sensing implemented
  • Ambient light interrupts working
  • Proximity sensing implemented
  • Proximity interrupts working
  • Gesture (UP, DOWN, LEFT, RIGHT, NEAR, FAR) sensing implemented

License Information

This product is open source!

The 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!

Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

sparkfun_apds-9960_sensor_arduino_library's People

Contributors

altaohms avatar andyengland521 avatar marshalltaylorsfe avatar mhord avatar patrice-sparkfun avatar tcirstea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkfun_apds-9960_sensor_arduino_library's Issues

why only APDS9960_GFIFO_U register is alone read ? line no:504

In line no: 504 of SparkFun_APDS9960.cpp file, only APDS9960_GFIFO_U register is read, why not the other registers like,
APDS9960_GFIFO_D
APDS9960_GFIFO_L
APDS9960_GFIFO_R
are not read while determining the gesture.

Anyone please provide me a suggestion...

Problem with NANO

Hey guys, not sure if anyone is still looking here but I have an issue with not original SparkFun APDS-9960 module but a "knock off".

Strange thing is that the module works perfectly on my UNO board but it doesn't on my NANO for some reason.

In gestureTest sketch NANO immediately receives interrupt signal and stats processing, even though there wasn't any input. Then it's stuck in the while(1) (while the data is valid) loop never escaping it.

I ran in debug mode my UNO and NANO, here are results:
UNO: https://pastebin.com/rexnAkSN
NANO: https://pastebin.com/7ERh3UwZ

I don't expect anything, but it's worth trying.

ESP8266 - SparkFun_APDS9960.h:202:1: error: expected declaration before '}' token

The following error occur when compiling a sketch for ESP8266:

SparkFun_APDS9960.h:202:1: error: expected declaration before '}' token

The sketch is the following:

/****************************************************************
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 <Arduino.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <SparkFun_APDS9960.h>

// Pins
#define APDS9960_INT    D3
#define MCU_SCL D1
#define MCU_SDA D2

// 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(115200);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
  
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  Wire.begin(MCU_SDA, MCU_SCL);

  // 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");
    }
  }
}

Possible divide by 0 error

Ratios in line 837 could possibly cause divide by 0 error if bounds check fails (line 785). Add a check beforehand to prevent this:

/* Catch to make sure we don't divide by 0 */
if( ((u_first + d_first) == 0) ||
    ((l_first + r_first) == 0) ||
    ((u_last + d_last) == 0) ||
    ((l_last + r_last) == 0) ) {

    return false;
}

Gesture sensor is now running, but doesn't log any gestures

Hey,

I recently bought a APDS 9960 sensor. I installed it to my Arduino (correctly, 3.3V) and tried the GestureTest.ino example, but I can't keep it to log the correctly. I've also tried the Proximity & ColorSensor examples which are working and logging correctly.

When I upload and run the GestureTest.ino, it returns the following information to the serial monitor.

SparkFun APDS-9960 - GestureTest
APDS-9960 initialization complete
Gesture sensor is now running

Does anybody know what's up?

LED_BOOST

Hi in the datasheet for the chip I see that LED_BOOST can bump current up to 300% , but looking through the library it looks by default it is already set at 300%. Am I reading the library right?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.