“Sensor-Gen&RGB/zh”的版本间的差异
第6行: | 第6行: | ||
|- | |- | ||
|[[File: Add-to-cart.jpg|300px|left|link=https://shop108263663.taobao.com/?spm=a230r.7195193.1997079397.2.ek3cAW]]|| | |[[File: Add-to-cart.jpg|300px|left|link=https://shop108263663.taobao.com/?spm=a230r.7195193.1997079397.2.ek3cAW]]|| | ||
− | ::<p style="color: #000000;font-size:120%">Sensor-Gen& | + | ::<p style="color: #000000;font-size:120%">Sensor-Gen&RGB是手势颜色传感器模块,可用于手势和颜色的识别。识别上、下、左、右、远、近等手势以及识别出不同颜色的RGB值 |
+ | </p> | ||
|} | |} | ||
<br> | <br> | ||
第99行: | 第100行: | ||
</source> | </source> | ||
'''颜色识别''' | '''颜色识别''' | ||
− | * | + | *本传感器识别出不同颜色的RGB值 |
*该例程效果为:下载程序后,保持USB线连接,打开串口(波特率设置为9600),观察返回值。 | *该例程效果为:下载程序后,保持USB线连接,打开串口(波特率设置为9600),观察返回值。 | ||
**用Sensor-Gen&RGB识别不同颜色的RGB值 | **用Sensor-Gen&RGB识别不同颜色的RGB值 |
2018年5月15日 (二) 08:41的版本
| |
|
技术规格
引脚
编程手册 手势识别
#include <Microduino_Gesture.h>
// Global Variables
Gesture gestureSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Initialize Gesture (configure I2C and initial values)
gestureSensor.begin() ;
// Start running the Gesture gesture sensor engine
gestureSensor.enableGestureSensor(true);
}
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");
}
}
}
颜色识别
#include <Microduino_Gesture.h>
// Global Variables
Gesture gestureSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Initialize Gesture (configure I2C and initial values)
gestureSensor.begin();
// Start running the Gesture light sensor (no interrupts)
gestureSensor.enableLightSensor(false);
}
void loop() {
// Read the light levels (ambient, red, green, blue)
Serial.print("Ambient: ");
Serial.print(gestureSensor.readAmbientLight());
Serial.print(" Red: ");
Serial.print(gestureSensor.readRedLight());
Serial.print(" Green: ");
Serial.print(gestureSensor.readGreenLight());
Serial.print(" Blue: ");
Serial.println(gestureSensor.readBlueLight());
// Wait 1 second before next reading
delay(1000);
}
在室内白色灯光且无阳光直射的环境下测试得到颜色RGB返回值为: 库语法手册 Sensor_Gen&RGB_Reference
文档
注意事项
示例教程
Q&A
历史
图库 |