网站要咋建立中国联通 腾讯
学物联网,来万物简单IoT物联网!!
一、产品简介
手势识别传感器PAJ7620u2是一款集成3D手势识别和运动跟踪为一体的交互式传感器,传感器可以在有效范围内识别手指的顺时针/逆时针转动方向和手指的运动方向等。它可以识别13种手势,包括向上移动,向下移动,向左移动,向右移动,向前移动,向后移动,顺时针方向,从左到右,从左到右等等手势姿态。
 传感器可以应用于各类互动的场景:可以挥一挥手定义你想完成的任何动作,比如挥一挥手可以关灯。
 
 引脚定义:
- VCC:3.3V
 - GND:地
 - SCL:I2C时钟
 - SDA:I2C数据
 - INT:中断引脚
 
二、技术参数
- 工作电压:3.3V-5V
 - 通讯方式:I2C接口
 - 手势识别:支持9种手势姿态
 - 工作温度:-40°C~85°C
 - 支持环境光:<100K Lux
 - 工作电流:3mA-10mA
 - 电路板尺寸:20mm * 15mm
 
三、软件接口
PAJ7620(i2cObj) - 创建PAJ7620传感器对象
- 函数原型
 
paj7620Obj = PAJ7620(i2cObj)
- 参数说明
 
| 参数 | 类型 | 必选参数? | 说明 | 
|---|---|---|---|
| i2cObj | I2C | 是 | 传入I2C对象 | 
- 返回值
 
PAJ7620对象成功,返回PAJ7620对象;PAJ7620对象创建失败,抛出Exception
- 示例代码
 
from machine import Pin,I2C
import paj7620i2cObj = I2C(1, scl=Pin(22), sda=Pin(21), freq=400000)
paj7620Obj = paj7620.PAJ7620(i2cobj)
print('start init paj7620')
 
- 输出
 
start init paj7620
 
setGestureHighrate(rate:bool) - 设置手势识别的速率
- 函数功能:
 
设置RTC时钟信息
- 函数原型:
 
PAJ7620.setDatetime(data)
- 参数说明:
 
rate:True-高速;False-慢速
- 返回值:
 
无
getGesture() - 获取检测到的姿势状态值
- 函数功能:
 
获取检测到的姿势状态值
- 函数原型:
 
gesture = PAJ7620.getGesture()
- 参数说明:
 
无
- 返回值:
 
成功返回gesture的手势姿态值
| gesture | 说明 | 
|---|---|
| 0 | 未检测姿态 | 
| 1 | 向右 | 
| 2 | 向左 | 
| 4 | 向上 | 
| 8 | 向下 | 
| 16 | 向前 | 
| 32 | 向后 | 
| 64 | 顺时针 | 
| 128 | 逆时针 | 
| 256 | 摇摆 | 
gestureDescription(gesture) - 获取手势姿势的描述信息
- 函数功能:
 
获取手势姿势的描述信息
- 函数原型:
 
description = PAJ7620.gestureDescription(gesture)
- 参数说明:
 
手势姿态状态值
- 返回值:
 
成功返回gesture的手势姿态描述
| gesture | description | 说明 | 
|---|---|---|
| 0 | None | 未检测姿态 | 
| 1 | Right | 向右 | 
| 2 | Left | 向左 | 
| 4 | Up | 向上 | 
| 8 | Down | 向下 | 
| 16 | Forward | 向前 | 
| 32 | Backward | 向后 | 
| 64 | Clockwise | 顺时针 | 
| 128 | Anti-Clockwise | 逆时针 | 
| 256 | Wave | 摇摆 | 
- 示例:
 
from machine import Pin,I2C
import paj7620i2cObj = I2C(1, scl=Pin(22), sda=Pin(21), freq=400000)
paj7620Obj = paj7620.PAJ7620(i2cobj)
print('start init paj7620')
paj7620Obj.setGestureHighrate(True)
gesture = paj7620Obj.getGesture()
description  = paj7620_obj.gestureDescription(gesture)
print("gesture code        = %d"%(gesture))
print("gesture description  = "+ description)
 
- 输出
 
start init paj7620
gesture code        = 2
gesture description  = Left
 
四、接口案例
- 案例代码
 
from machine import Pin,I2C
import paj7620
import utimepaj7620_obj = Nonedef paj7620_init():global paj7620Obji2cObj = I2C(1, scl=Pin(22), sda=Pin(21), freq=400000)paj7620Obj = paj7620.PAJ7620(i2cobj)print('start init paj7620')paj7620Obj.setGestureHighrate(True)if __name__ == '__main__':paj7620_init()while True:gesture = paj7620Obj.getGesture()if gesture != paj7620Obj.GESTURE_NONE:description  = paj7620Obj.gestureDescription(gesture)print("--------------Gesture Recognition System---------------------------")print("gesture code        = %d"%(gesture))print("gesture description  = "+ description)
 
- 输出
 
start init paj7620
--------------Gesture Recognition System---------------------------
gesture code        = 1
gesture description  = Right
--------------Gesture Recognition System---------------------------
gesture code        = 4
gesture description  = Up
--------------Gesture Recognition System---------------------------
gesture code        = 8
gesture description  = Down
--------------Gesture Recognition System---------------------------
gesture code        = 1
gesture description  = Right
--------------Gesture Recognition System---------------------------
gesture code        = 2
gesture description  = Left
--------------Gesture Recognition System---------------------------
gesture code        = 2
gesture description  = Left
 
参考文献及购买链接
[1] PAJ7620手势识别传感器购买链接

