手势传感器PAJ7620U2
最近买了个手势传感器,可以直接通过GPIO口连接树莓派,测试了下用手势识别控制无人机。
视频见:https://www.bilibili.com/video/BV1hT4y1j7Wz
【无人机】手势传感器控制无人机飞行
识别手势:上、下、左、右、前、后、顺时针、逆时针、摇摆
识别距离:5-15cm
微雪资料
1.软件下载
程序
文档
调试程序
2.准备工作
2.1 硬件
打开I2C接口
连线
2.2 软件库
sudo apt-get install python-pip
sudo pip install RPi.GPIO
sudo pip install spidev
sudo apt-get install python-pil
sudo apt-get install python-smbus
sudo apt-get install python-serial
3.Python例程
#!/usr/bin/python
# -*- coding:utf-8 -*-
import time
import smbus
#i2c address
PAJ7620U2_I2C_ADDRESS = 0x73
#Register Bank select
PAJ_BANK_SELECT = 0xf0 #Bank0== 0x00,Bank1== 0x01
#Register Bank 0
PAJ_SUSPEND = 0x03 #I2C suspend command (Write = 0x01 to enter suspend state). I2C wake-up command is slave ID wake-up. Refer to topic “I2C Bus Timing Characteristics and Protocol”
PAJ_INT_FLAG1_MASK = 0x41 #Gesture detection interrupt flag mask
PAJ_INT_FLAG2_MASK = 0x42 #Gesture/PS detection interrupt flag mask
PAJ_INT_FLAG1 = 0x43 #Gesture detection interrupt flag
PAJ_INT_FLAG2 = 0x44 #Gesture/PS detection interrupt flag
PAJ_STATE = 0x45 #State indicator for gesture detection (Only functional at gesture detection mode)
PAJ_PS_HIGH_THRESHOLD = 0x69 #PS hysteresis high threshold (Only functional at proximity detection mode)
PAJ_PS_LOW_THRESHOLD = 0x6A #PS hysteresis low threshold (Only functional at proximity detection mode)
PAJ_PS_APPROACH_STATE = 0x6B #PS approach state, Approach = 1 , (8 bits PS data >= PS high threshold), Not Approach = 0 , (8 bits PS data <= PS low threshold)(Only functional at proximity detection mode)
PAJ_PS_DATA = 0x6C #PS 8 bit data(Only functional at gesture detection mode)
PAJ_OBJ_BRIGHTNESS = 0xB0 #Object Brightness (Max. 255)
PAJ_OBJ_SIZE_L = 0xB1 #Object Size(Low 8 bit)
PAJ_OBJ_SIZE_H = 0xB2 #Object Size(High 8 bit)
#Register Bank 1
PAJ_PS_GAIN = 0x44 #PS gain setting (Only functional at proximity detection mode)
PAJ_IDLE_S1_STEP_L = 0x67 #IDLE S1 Step, for setting the S1, Response Factor(Low 8 bit)
PAJ_IDLE_S1_STEP_H = 0x68 #IDLE S1 Step, for setting the S1, Response Factor(High 8 bit)
PAJ_IDLE_S2_STEP_L = 0x69 #IDLE S2 Step, for setting the S2, Response Factor(Low 8 bit)
PAJ_IDLE_S2_STEP_H = 0x6A #IDLE S2 Step, for setting the S2, Response Factor(High 8 bit)
PAJ_OPTOS1_TIME_L = 0x6B #OPtoS1 Step, for setting the OPtoS1 time of operation state to standby 1 state(Low 8 bit)
PAJ_OPTOS2_TIME_H = 0x6C #OPtoS1 Step, for setting the OPtoS1 time of operation state to standby 1 stateHigh 8 bit)
PAJ_S1TOS2_TIME_L = 0x6D #S1toS2 Step, for setting the S1toS2 time of standby 1 state to standby 2 state(Low 8 bit)
PAJ_S1TOS2_TIME_H = 0x6E #S1toS2 Step, for setting the S1toS2 time of standby 1 state to standby 2 stateHigh 8 bit)
PAJ_EN = 0x72 #Enable/Disable PAJ7620U2
#Gesture detection interrupt flag
PAJ_UP = 0x01
PAJ_DOWN = 0x02
PAJ_LEFT = 0x04
PAJ_RIGHT = 0x08
PAJ_FORWARD = 0x10
PAJ_BACKWARD = 0x20
PAJ_CLOCKWISE = 0x40
PAJ_COUNT_CLOCKWISE = 0x80
PAJ_WAVE = 0x100
#Power up initialize array
Init_Register_Array = (
(0xEF,0x00),
(0x37,0x07),
(0x38,0x17),
(0x39