SEN0187 RGB and Gesture Sensor
Contents
1 Introduction
2 Specification
3 Layout
4 Tutorial
4.1 Requirements
4.2 Connection Diagram
4.3 How to use
4.3.1 Codes download
4.3.2 Sample Code
4.4 Other functions
5 Protocol/Library Explanation
6 Trouble Shooting
Introduction
The sensor module uses the APDS-9960 chip, this is a single 8 pin package digital RGB, ambient
light, short and gesture sensor device. The device is compatible with I2C interface, with an interruput
pin. And short-range and gestures are measured with infrared LED. RGB and environmental light
perception measurement function could work under a variety of light conditions, such as covering by
a variety of damping materials including a piece of dark glass. In addition, the integrated UV-IR
shading filter can realize ambient light and color temperature detecting.
Specification
Operating Voltage: 3.3-5V
Interface:
I2C interface x1
Interrupt pin x1
Detecting range: 100mm
Module size: 18.3x16.4mm
Layout
RGB and Gesture Sensor
OPSITIVE
名称
RGB and Gesture Sensor
REVERSE
功能描述
SDA
I2C DATA PORT
SCL
I2C CLOCK PORT
GND
GND
VCC
VCC
INT
Interrupt Output
Tutorial
We will use a simple example to teach you how to use the gesture Sensor. Our goal is to make the
sensor to detect gestures up and down around the waving.
Requirements
Hardware
UNO x1
RGB and Gesture Sensor x1
Software
Arduino IDE V1.6.5 Click to Download Arduino IDE
https://www.arduino.cc/en/Main/Software
Connection Diagram
Sensor Pin
UNO Pin
VCC
5V
GND
GND
SCL
SCL
SDA
SDA
INT
2
How to use
In this section, we will use a simple experiment to teach you how to use our gesture sensor. Our
goal is to get the sensor detect the gesture UP, DOWN, left and right. Here we begin.
Codes download
Download and install the RGB and Gesture Sensor Library:
Click to download library files
https://github.com/Arduinolibrary/DFRobot_RGB_and_gesture_sensor/raw/master/SparkFun_APDS
9960.zip
Arduino Library Installation Tutorial https://www.arduino.cc/en/Guide/Libraries#.UxU8mdzF9H0
Next, we need to open the ARDUINO IDE, and copy the following simple code to the IDE window.
Then select the right serial port and board (Arduino UNO). Wave your hand in front of the sensor,
see what happen on the serial port.
Sample Code
1 #include
2 #include
3
4 // Pins
5 #define APDS9960_INT
2 // Needs to be an interrupt pin
6
7 APDS9960 apds = APDS9960();
8 int isr_flag = 0;
9
10 void setup() {
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
25
Serial.println(F("APDS-9960 initialization complete"));
} else {
26
27
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
28
29
// Start running the APDS-9960 gesture sensor engine
30
if ( apds.enableGestureSensor(true) ) {
31
32
Serial.println(F("Gesture sensor is now running"));
} else {
33
34
Serial.println(F("Something went wrong during gesture sensor init!"));
}
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
}
45
46
isr_flag = 0;
}
47 }
48
49 void interruptRoutine() {
50
isr_flag = 1;
51 }
52
53 void handleGesture() {
54
if ( apds.isGestureAvailable() ) {
55
switch ( apds.readGesture() ) {
56
case DIR_UP:
57
Serial.println("UP");
58
break;
59
case DIR_DOWN:
60
Serial.println("DOWN");
61
break;
62
case DIR_LEFT:
63
Serial.println("LEFT");
64
break;
65
case DIR_RIGHT:
66
Serial.println("RIGHT");
67
break;
68
case DIR_NEAR:
69
Serial.println("NEAR");
70
break;
71
case DIR_FAR:
72
Serial.println("FAR");
73
break;
74
default:
75
Serial.println("NONE");
76
77
}
}
78 }
Other functions
This sensor not only support gesture recognition, but also the range, ambient light and RGB color
detecting. The specific examples can be found in the library EXAMPLES folder. so you can also
develop other application according to your requirement.
Protocol/Library Explanation
I2C Protocol https://en.wikipedia.org/wiki/I%C2%B2C
Trouble Shooting
Any question and more cool ideas to share, please visit DFRobot Forum
Powered By DFRobot © 2008-2017
很抱歉,暂时无法提供与“SEN0187”相匹配的价格&库存,您可以联系我们找货
免费人工找货- 国内价格 香港价格
- 1+162.315291+19.42470
- 3+143.147173+17.13080
- 国内价格
- 1+134.27338
- 3+126.93087