一.手势传感器介绍
APDS-9960
具有先进的手势检测,接近检测和数字环境光感应功能,是一个采用单个8引脚封装的数字RGB,环境光,近程和手势传感器。该装置具有I2C兼容的接口,为红色,绿色,蓝色,和透明(RGBC),近程和手势感测配有LED红外,
APDS-9930
https://github.com/Depau/APDS9930
二.接线图
GND | GND |
---|---|
VCC | 3.3V |
SDA | A4 |
SCL | A5 |
https://codeload.github.com/adafruit/Adafruit_APDS9960/zip/master
include "Adafruit_APDS9960.h"
Adafruit_APDS9960 apds;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(115200);
if(!apds.begin()){
Serial.println("failed to initialize device! Please check your wiring.");
}
else Serial.println("Device initialized!");
//gesture mode will be entered once proximity mode senses something close
apds.enableProximity(true);
apds.enableGesture(true);
}
// the loop function runs over and over again forever
void loop() {
//read a gesture from the device
uint8_t gesture = apds.readGesture();
if(gesture == APDS9960_DOWN) Serial.println("v");
if(gesture == APDS9960_UP) Serial.println("^");
if(gesture == APDS9960_LEFT) Serial.println("<");
if(gesture == APDS9960_RIGHT) Serial.println(">");
}