9/25/2015
Grove Gesture v1.0 Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0
7/10
void
setup
()
{
paj7620Init
()
;
}
This initialization code should be added to each demo.
2. Read data from PAJ7620 register via I2C
paj7620ReadReg(uint8_t addr, uint8_t qty, uint8_t data[])
addr: Register address
qty: Number of data to read, addr continuously increase.
data[]: The starting address(a variable or array) to store data.
void
loop
()
{
uint8_t data
=
0
;
// Read Bank_0_Reg_0x43/0x44 for gesture result.
paj7620ReadReg
(
0x43
,
1
,
&
data
)
;
// When different gestures be detected, the variable 'data' will be set to different values by paj7620ReadReg(0x43, 1, &data).
if
(
data
==
GES_UP_FLAG
)
// When up gesture be detected,the variable 'data' will be set to GES_UP_FLAG.
digitalWrite
(
4
,
HIGH
)
;
// turn the LED on (HIGH is the voltage level)
if
(
data
==
GES_DOWN_FLAG
)
// When down gesture be detected,the variable 'data' will be set to GES_DOWN_FLAG.
digitalWrite
(
4
,
LOW
)
;
// turn the LED off by making the voltage LOW
}
We define some register data of gesture, refer to the following table.
Gesture
Register Data
Register
Address
If Yes
If Not
Up
data==GES_UP_FLAG
0x43
Gesture
detected
No gesture
detected
Down
data==GES_DOWN_FLAG
Left
data==GES_LEFT_FLAG
Right
data==GES_RIGHT_FLAG
Forward
data==GES_FORWARD_FLAG
Backward
data==GES_BACKWARD_FLAG
Clockwise
data==GES_CLOCKWISE_FLAG
Count
Clockwise
data==GES_COUNT_CLOCKWISE_FLAG
Wave
data==GES_WAVE_FLAG
0x44