“Sensor-Gesture/zh”的版本间的差异
Zhangfengfeng(讨论 | 贡献) (→文档) |
502748957@qq.com(讨论 | 贡献) (→开发) |
||
(未显示3个用户的5个中间版本) | |||
第4行: | 第4行: | ||
| | | | ||
[[File:Microduino-Gesture.jpg|400px|thumb|right|Sensor-Gesture]] | [[File:Microduino-Gesture.jpg|400px|thumb|right|Sensor-Gesture]] | ||
− | + | Sensor-Gesture产品编号:'''MSDI81''' | |
Sensor-Gesture是手势传感器,可以检测手的运动方向和远近程度 | Sensor-Gesture是手势传感器,可以检测手的运动方向和远近程度 | ||
第29行: | 第29行: | ||
**板子大小:23.5mm*13mm | **板子大小:23.5mm*13mm | ||
**1.27mm间距的4Pin接口与sensorhub相连 | **1.27mm间距的4Pin接口与sensorhub相连 | ||
− | **传感器CAD图纸:'''[[File:Sensor_CAD. | + | **传感器CAD图纸:'''[[File:Sensor_CAD.pdf]]''' |
*功能描述 | *功能描述 | ||
第37行: | 第37行: | ||
*接法 | *接法 | ||
**本传感器可连接到核心的I2C接口 | **本传感器可连接到核心的I2C接口 | ||
− | |||
− | |||
− | |||
==开发== | ==开发== | ||
===程序下载=== | ===程序下载=== | ||
− | + | 复制如下程序至Microduino IDE中,可以测试手势检测功能是否正常。 | |
+ | 使用时正对传感器,做出标准的向左、向右、向上、向下的挥手动作,观察串口返回值 | ||
+ | <source lang="cpp"> | ||
+ | #include <Microduino_Gesture.h> | ||
+ | |||
+ | // Global Variables | ||
+ | Gesture gestureSensor; | ||
+ | |||
+ | void setup() { | ||
+ | // Initialize Serial port | ||
+ | Serial.begin(9600); | ||
+ | |||
+ | // Initialize Gesture (configure I2C and initial values) | ||
+ | if ( gestureSensor.begin() ) { | ||
+ | Serial.println(F("Gesture initialization complete")); | ||
+ | } else { | ||
+ | Serial.println(F("Something went wrong during Gesture init!")); | ||
+ | } | ||
+ | |||
+ | if (gestureSensor.setGestureGain(GGAIN_2X)) { //GGAIN_1X GGAIN_2X GGAIN_4X GGAIN_8X | ||
+ | Serial.println(F("Gesture setGestureGain complete")); | ||
+ | } else { | ||
+ | Serial.println(F("Something went wrong during APDS-9960 setGestureGain!")); | ||
+ | } | ||
+ | |||
+ | // Start running the Gesture gesture sensor engine | ||
+ | if ( gestureSensor.enableGestureSensor(true) ) { | ||
+ | Serial.println(F("Gesture sensor is now running")); | ||
+ | } else { | ||
+ | Serial.println(F("Something went wrong during gesture sensor init!")); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if ( gestureSensor.isGestureAvailable() ) { | ||
+ | switch ( gestureSensor.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"); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
===程序烧写=== | ===程序烧写=== | ||
第62行: | 第118行: | ||
*下载完毕后,打开串口监视器 | *下载完毕后,打开串口监视器 | ||
*手对着传感器上下左右运动,串口监视器会打印出对应的方向,例如UP,DOWN,FAR | *手对着传感器上下左右运动,串口监视器会打印出对应的方向,例如UP,DOWN,FAR | ||
+ | |||
==应用== | ==应用== | ||
*适用于手势控制系统 | *适用于手势控制系统 | ||
− | ==项目 | + | ==项目== |
==购买== | ==购买== |
2018年11月15日 (四) 10:10的最新版本
Language | English |
---|
Sensor-Gesture产品编号:MSDI81 Sensor-Gesture是手势传感器,可以检测手的运动方向和远近程度 传感器引脚说明
特色
规格
开发程序下载复制如下程序至Microduino IDE中,可以测试手势检测功能是否正常。 使用时正对传感器,做出标准的向左、向右、向上、向下的挥手动作,观察串口返回值 #include <Microduino_Gesture.h>
// Global Variables
Gesture gestureSensor;
void setup() {
// Initialize Serial port
Serial.begin(9600);
// Initialize Gesture (configure I2C and initial values)
if ( gestureSensor.begin() ) {
Serial.println(F("Gesture initialization complete"));
} else {
Serial.println(F("Something went wrong during Gesture init!"));
}
if (gestureSensor.setGestureGain(GGAIN_2X)) { //GGAIN_1X GGAIN_2X GGAIN_4X GGAIN_8X
Serial.println(F("Gesture setGestureGain complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 setGestureGain!"));
}
// Start running the Gesture gesture sensor engine
if ( gestureSensor.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running"));
} else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
}
void loop() {
if ( gestureSensor.isGestureAvailable() ) {
switch ( gestureSensor.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");
}
}
}
程序烧写
硬件搭建
效果观察
应用
项目购买图库 |