arduino体感控制简单版

https://learn.sparkfun.com/tutorials/apds-9960-rgb-and-gesture-sensor-hookup-guide/all

arduino体感控制简单版

硬件连线

关键 VCC=  3.3v  不是 5v

arduino体感控制简单版

arduino体感控制简单版

下面这个库实测不起作用,不知道为什么

arduino体感控制简单版

可用的库

arduino体感控制简单版

程序

/*
APDS9960 - Gesture Sensor This example reads gesture data from the on-board APDS9960 sensor of the
Nano 33 BLE Sense and prints any detected gestures to the Serial Monitor. Gesture directions are as follows:
- UP: from USB connector towards antenna
- DOWN: from antenna towards USB connector
- LEFT: from analog pins side towards digital pins side
- RIGHT: from digital pins side towards analog pins side The circuit:
- Arduino Nano 33 BLE Sense This example code is in the public domain.
*/ #include <Arduino_APDS9960.h> void setup() {
Serial.begin(9600);
while (!Serial); if (!APDS.begin()) {
Serial.println("Error initializing APDS9960 sensor!");
} // for setGestureSensitivity(..) a value between 1 and 100 is required.
// Higher values makes the gesture recognition more sensible but less accurate
// (a wrong gesture may be detected). Lower values makes the gesture recognition
// more accurate but less sensible (some gestures may be missed).
// Default is 80
//APDS.setGestureSensitivity(80); Serial.println("Detecting gestures ...");
}
void loop() {
if (APDS.gestureAvailable()) {
// a gesture was detected, read and print to serial monitor
int gesture = APDS.readGesture(); switch (gesture) {
case GESTURE_UP:
Serial.println("Detected UP gesture");
break; case GESTURE_DOWN:
Serial.println("Detected DOWN gesture");
break; case GESTURE_LEFT:
Serial.println("Detected LEFT gesture");
break; case GESTURE_RIGHT:
Serial.println("Detected RIGHT gesture");
break; case GESTURE_DOWN:
Serial.println("Detected DOWN gesture");
break;
default:
// ignore
break;
}
}
}

1测试的时候刚上电不要对着强光,否则触发不了。

此函数来调整光触发值,0-100  默认80

arduino体感控制简单版

应该是有一个光照强度值,跟初始上电瞬间采集到的光照有关系,基准值,发现触发不了的情况,断电,不要对着强光重启,复位不行。

2实际测试,其他物体也可以触发

还有2种其他手势可用:NEAR和FAR。

将手放在传感器上方(大于10英寸(25厘米)),使其靠近传感器(在传感器上方约2英寸(5厘米)),将其保持在至少1秒钟,然后移开您的手。

可以通过以下方式实现FAR手势:将手直接放在传感器上方并靠近传感器(大约2英寸(5厘米))至少1秒钟,然后将手直接向上移至传感器上方并超出传感器范围。

如果未正确解释手势,则“无”将出现在串行监视器中。

arduino体感控制简单版

arduino体感控制简单版

上一篇:关于spring事务


下一篇:【20181023T3】“新”的家园【虚图】