“SKU:RB-02S102 Gesture Sensor”的版本間的差異
來自ALSROBOT WiKi
(→?庫文件下載) |
|||
第14行: | 第14行: | ||
==使用方法== | ==使用方法== | ||
===庫文件下載=== | ===庫文件下載=== | ||
? | * 庫文件下載地址:[ | + | * 庫文件下載地址:[http://pan.baidu.com/s/1o8GZz6M ALSROBOT] |
* 庫文件安裝詳細(xì)方法:[http://www.makerspace.cn/forum.php?mod=viewthread&tid=6647&fromuid=10780 Arduino 庫文件加載方法] | * 庫文件安裝詳細(xì)方法:[http://www.makerspace.cn/forum.php?mod=viewthread&tid=6647&fromuid=10780 Arduino 庫文件加載方法] | ||
+ | |||
===例子程序=== | ===例子程序=== | ||
1、測試環(huán)境<br/> | 1、測試環(huán)境<br/> |
2016年12月5日 (一) 13:08的版本
目錄 |
產(chǎn)品概述
Gesture Sensor模塊是基于APDS-9960傳感器的一款能夠識別手勢移動方向(上下左右)的傳感器模塊。APDS-9960芯片集成了RGB、環(huán)境光、接近和手勢檢測功能。模塊使用I2C接口,使用相應(yīng)arduino庫函數(shù)即可對編程控制,傳感器返回的信號可用于作為機(jī)器人接收的控制信號,從而實(shí)現(xiàn)對機(jī)器人的控制。內(nèi)置的識別算法相當(dāng)智能,能夠把雙手從生硬的按鍵中解放出來。
產(chǎn)品參數(shù)
- 輸入電壓:3.3V - 5V
- 引腳接口:IIC接口* 1、中斷引腳 * 1
- 接口類型:直插、KF2510
- 輸出信號:數(shù)字
- 產(chǎn)品尺寸:30 mm * 25 mm
- 定位孔:4 * M3,間距 23mm x 18mm
- 檢測距離:10 cm
- 重量大?。?g
使用方法
庫文件下載
- 庫文件下載地址:ALSROBOT
- 庫文件安裝詳細(xì)方法:Arduino 庫文件加載方法
例子程序
1、測試環(huán)境
- 硬件環(huán)境:Starduino UNO R3 、傳感器V5.0擴(kuò)展板、紅外手勢傳感器、8*8點(diǎn)陣
- 軟件環(huán)境:Arduino IDE 1.7.7
2、引腳定義
- -:電源地
- +:電源正極
- SDA:數(shù)據(jù)引腳
- SCL:時(shí)引腳
3、硬件連接
4、例子程序
#include <Wire.h> #include <ALSROBOT_APDS9960.h> const int DINPin = 4; //數(shù)據(jù)引腳 連接到數(shù)字P4口 const int CLKPin = 5; //時(shí)鐘引腳 連接到數(shù)字P5口 const int LTHPin = 6; //鎖存引腳 連接到數(shù)字P6口 byte LieScan[16] = { //列掃描,點(diǎn)陣只點(diǎn)亮一列 0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F }; byte HanZi_1[] = { 0x1c,0x7c,0x7e,0x3f,0x3f,0x7e,0x7c,0x1c //顯示心形圖案 }; char Left[]={0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x00}; char Down[]={0x00,0x10,0x30,0x7e,0x7e,0x30,0x10,0x00}; char Up[]={0x00,0x08,0x0c,0x7e,0x7e,0x0c,0x08,0x00}; char Right[]={0x00,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00}; char Far[]={0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0xff}; char Near[]={0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00}; char Moren[]={0x18,0x3c,0x5a,0xff,0xff,0x5a,0x3c,0x18}; ALSROBOT_APDS9960 apds = ALSROBOT_APDS9960(); int isr_flag = 0; int temp=0; void setup() { pinMode(DINPin,OUTPUT); //設(shè)置數(shù)據(jù)引腳為輸出 pinMode(CLKPin,OUTPUT); //設(shè)置鎖存引腳為輸出 pinMode(LTHPin,OUTPUT); //設(shè)置時(shí)鐘引腳為輸出 // Initialize Serial port Serial.begin(9600); Serial.println(); Serial.println(F("--------------------------------")); Serial.println(F("ALSROBOT APDS-9960 - GestureTest")); Serial.println(F("--------------------------------")); if ( apds.init() ) { Serial.println(F("APDS-9960 initialization complete")); } else { Serial.println(F("Something went wrong during APDS-9960 init!")); } // Start running the APDS-9960 gesture sensor engine if ( apds.enableGestureSensor(true) ) { Serial.println(F("Gesture sensor is now running")); } else { Serial.println(F("Something went wrong during gesture sensor init!")); } } void left(){ for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, Left[x]); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void down() { for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, Down[x]); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void up() { for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, Up[x]); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void right() { for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, Right[x]); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void far() { for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, Far[x]); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void near() { for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, Near[x]); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void moren() { for(unsigned char times_1 = 0;times_1 <250;times_1++) { //持續(xù)刷新250次 for(char x = 0;x <8;x++) { shiftOut(DINPin, CLKPin, MSBFIRST, LieScan[x]); //先選擇列 shiftOut(DINPin, CLKPin, MSBFIRST, 0x00); //再送行數(shù)據(jù) digitalWrite(LTHPin, LOW); //刷新顯示 digitalWrite(LTHPin, HIGH); } } } void loop() { switch(temp) { case 1:up();break; case 2:down();break; case 3:left();break; case 4:right();break; case 5:near();break; case 6:far();break; default :moren();break; } handleGesture(); } void handleGesture() { if ( apds.isGestureAvailable() ) { switch ( apds.readGesture() ) { case DIR_UP: temp=1; Serial.println("UP"); break; case DIR_DOWN: temp=2; Serial.println("DOWN"); break; case DIR_LEFT: temp=3; Serial.println("LEFT"); break; case DIR_RIGHT: temp=4; Serial.println("RIGHT"); break; case DIR_NEAR: temp=5; Serial.println("NEAR"); break; case DIR_FAR: temp=6; Serial.println("FAR"); break; default:temp=7; Serial.println("NONE"); } } }
5、程序效果 如圖所示,當(dāng)手滑動時(shí),點(diǎn)陣顯示相應(yīng)的滑動方向