seeed studio PAJ7620U2 User manual

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 2/10
4WithArduino/Seeeduino
4.1SuggestReadingforStarter
4.2HardwareInstallation
4.3GestureLibrary
4.3.1Setup
4.3.2SimpleDemo
4.3.3Descriptionoffunctions
4.3.3.11.InitializethegesturesensorchipPAJ7620
4.3.3.22.ReaddatafromPAJ7620registerviaI2C
4.4GestureExamples/Applications
5Resources
Introduction
ThesensoronGrove-GestureisPAJ7620U2thatintegratesgesturerecognitionfunction
withgeneralI2Cinterfaceintoasinglechip.Itcanrecognize9basicgestures,andthese
gesturesinformationcanbesimplyaccessedviatheI2Cbus.
Application:YoucanuseGestureasaninputdevicetocontrolanothergrove,ora
computer,mobilephone,smartcar,robot,andmorewithasimpleswipeofyourhand.
Features
1See9gesturesinthefollowingfigure
9basic
gestures
Up
Down
Left
Right
Forward
Backward
Clockwise
Count
Clockwise
Wave

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 3/10
2Built-inproximitydetection
3Variousmainboardssupport:ArduinoUNO/Seeeduino/ArduinoMega2560
Specification
Sensor PAJ7620U2
Powersupply 5V
Ambientlightimmunity <100kLux
GesturespeedinNormalMode 60°/sto600°/s
GesturespeedinGamingMode 60°/sto1200°/s
Interfacetype IICinterfaceupto400kbit/s
OperatingTemperature -40°Cto+85°C
Dimensions 20*20mm
Detectionrange 5-15mm
WithArduino/Seeeduino
SuggestReadingforStarter
DownloadArduinoandinstallArduinodriver
(http://www.seeedstudio.com/wiki/Download_Arduino_and_install_Arduino_driver)
GettingStartedwithSeeeduino/Arduino
(http://www.seeedstudio.com/wiki/Getting_Started_with_Seeeduino)
HardwareInstallation
Groveproductshaveaecosystemandallhaveasameconnectorwhichcanplugontothe
BaseShield(http://www.seeedstudio.com/wiki/index.php?title=Base_shield_v2&uselang=en)
.ConnectthismoduletotheI2CportofBaseShield,however,youcanalsoconnectGrove-
GesturetoArduinowithoutBaseShieldbyjumperwires.
ArduinoUNO BaseShield Grove-Gesture
5V
I2Cport
VCC
GND GND
SDA SDA
SCL SCL
Digit2 Notconnected INT(Reservedpad)
INT:Gesturedetectioninterruptflagmask.YoucanconnectINTpadtodigit2ofArduino
byusingjumperwire.

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 5/10
GestureLibrary
WehavecreatedalibrarytohelpyoustartplayingquicklywiththeSeeeduino/Arduino,in
thissectionwe'llshowyouhowtosetupthelibraryandintroducesomeofthefunctions.
Setup
1. DownloadthelibrarycodeasazipfilefromtheGesture_PAJ7620githubpage.
(https://github.com/Seeed-Studio/Gesture_PAJ7620)
2. Unzipthedownloadedfileintoyour…/arduino/libraries.
3. Renametheunzippedfolder"Gesture"(or:"Gesture_PAJ7620")
4. StarttheArduinoIDE(orrestartifitisopen).
SimpleDemo
Thefollowingsimpledemowillshowyouaveryeasyapplication:Whenyoumoveup,the
redledwillbeturnedon,otherwisetheredledwillbeturnedoff.
#include<Wire.h>
#include"paj7620.h"

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 6/10
#include"paj7620.h"
voidsetup()
{
paj7620Init();
}
voidloop()
{
uint8_tdata=0;//ReadBank_0_Reg_0x43/0x44forgestureresult.
paj7620ReadReg(0x43,1,&data);//Whendifferentgesturesbedetected,thevariable'data'willbesettodifferentvaluesbypaj7620ReadReg(0x43,1,&data).
if(data==GES_UP_FLAG) //Whenupgesturebedetected,thevariable'data'willbesettoGES_UP_FLAG.
digitalWrite(4,HIGH); //turntheLEDon(HIGHisthevoltagelevel)
if(data==GES_DOWN_FLAG) //Whendowngesturebedetected,thevariable'data'willbesettoGES_DOWN_FLAG.
digitalWrite(4,LOW); //turntheLEDoffbymakingthevoltageLOW
}
Descriptionoffunctions
Thesearethemostimportant/usefulfunctioninthelibrary,weinviteyoutolookatthe.h
and.cppfilesyourselftoseeallthefunctionsavailable.
1.InitializethegesturesensorchipPAJ7620

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 7/10
voidsetup()
{
paj7620Init();
}
Thisinitializationcodeshouldbeaddedtoeachdemo.
2.ReaddatafromPAJ7620registerviaI2C
paj7620ReadReg(uint8_taddr,uint8_tqty,uint8_tdata[])
addr:Registeraddress
qty:Numberofdatatoread,addrcontinuouslyincrease.
data[]:Thestartingaddress(avariableorarray)tostoredata.
voidloop()
{
uint8_tdata=0;//ReadBank_0_Reg_0x43/0x44forgestureresult.
paj7620ReadReg(0x43,1,&data);//Whendifferentgesturesbedetected,thevariable'data'willbesettodifferentvaluesbypaj7620ReadReg(0x43,1,&data).
if(data==GES_UP_FLAG) //Whenupgesturebedetected,thevariable'data'willbesettoGES_UP_FLAG.
digitalWrite(4,HIGH); //turntheLEDon(HIGHisthevoltagelevel)
if(data==GES_DOWN_FLAG) //Whendowngesturebedetected,thevariable'data'willbesettoGES_DOWN_FLAG.
digitalWrite(4,LOW); //turntheLEDoffbymakingthevoltageLOW
}
Wedefinesomeregisterdataofgesture,refertothefollowingtable.
Gesture RegisterData Register
Address IfYes IfNot
Up data==GES_UP_FLAG
0x43 Gesture
detected
Nogesture
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

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 8/10
GestureExamples/Applications
TheseexamplesaregoingtoshowyouhowtorecognizegesturesfromthisGrove-
Gesture.
OpenFile->Examples->Gesture(or:Gesture_PAJ7620)->example-
>paj7620_9gesturessketchforacompleteexample.
Description:Thisexamplecanrecognize9gesturesandoutputtheresult,including
moveup,movedown,moveleft,moveright,moveforward,movebackward,circle-
clockwise,circle-counterclockwise,andwave.YoualsocanuseGestureasaninput
devicetocontrolanothergrove,oracomputer,mobilephone,smartcar,robot,and
morewithasimpleswipeofyourhand.
Notice:WhenyouwanttorecognizetheForward/Backwardgestures,yourgestures'
reactiontimemustlessthanGES_ENTRY_TIME(0.8s).Youalsocanadjustthereaction
timeaccordingtotheactualcircumstance.
/*
Notice:WhenyouwanttorecognizetheForward/Backwardgestures,yourgestures'reactiontimemustlessthanGES_ENTRY_TIME(0.8s).
Youalsocanadjustthereactiontimeaccordingtotheactualcircumstance.
*/
#defineGES_REACTION_TIME 500 //Youcanadjustthereactiontimeaccordingtotheactualcircumstance.
#defineGES_ENTRY_TIME 800 //WhenyouwanttorecognizetheForward/Backwardgestures,yourgestures'reactiontimemustlessthanGES_ENTRY_TIME(0.8s).
#defineGES_QUIT_TIME 1000
Followingarethemainprogramusedinthedemo:
voidsetup()
{
uint8_terror=0;
Serial.begin(9600);
Serial.println("\nPAJ7620U2TESTDEMO:Recognize9gestures.");
error=paj7620Init(); //initializePaj7620registers
if(error)
{
Serial.print("INITERROR,CODE:");
Serial.println(error);
}
else
{
Serial.println("INITOK");
}
Serial.println("Pleaseinputyourgestures:\n");
}
voidloop()
{
uint8_tdata=0,data1=0,error;
error=paj7620ReadReg(0x43,1,&data); //ReadBank_0_Reg_0x43/0x44forgestureresult.
if(!error)
{
switch(data) //Whendifferentgesturesbedetected,thevariable'data'willbesettodifferentvaluesbypaj7620ReadReg(0x43,1,&data).
{
caseGES_RIGHT_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43,1,&data);

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 9/10
paj7620ReadReg(0x43,1,&data);
if(data==GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
}
elseif(data==GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
}
else
{
Serial.println("Right");
}
break;
caseGES_LEFT_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43,1,&data);
if(data==GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
}
elseif(data==GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
}
else
{
Serial.println("Left");
}
break;
caseGES_UP_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43,1,&data);
if(data==GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
}
elseif(data==GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
}
else
{
Serial.println("Up");
}
break;
caseGES_DOWN_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43,1,&data);
if(data==GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
}
elseif(data==GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
}
else
{
Serial.println("Down");
}
break;
caseGES_FORWARD_FLAG:
Serial.println("Forward");
delay(GES_QUIT_TIME);
break;
caseGES_BACKWARD_FLAG:
Serial.println("Backward");
delay(GES_QUIT_TIME);
break;
caseGES_CLOCKWISE_FLAG:
↑TOP

9/25/2015 GroveGesturev1.0Wiki
http://www.seeedstudio.com/wiki/Grove__Gesture_v1.0 10/10
caseGES_CLOCKWISE_FLAG:
Serial.println("Clockwise");
break;
caseGES_COUNT_CLOCKWISE_FLAG:
Serial.println("anti‐clockwise");
break;
default:
paj7620ReadReg(0x44,1,&data1);
if(data1==GES_WAVE_FLAG)
{
Serial.println("wave");
}
break;
}
}
delay(100);
}
Inyourownproject,youmayneedmulti-gesturesinsteadofasinglegesturetorealise
onefunction,welcometoshare!
Resources
Grove-Gesture_v1.0schpcb.zip(http://www.seeedstudio.com/wiki/File:Grove_-
_Gesture_v1.0_sch_pcb.zip)
PAJ7620U2_Datasheet_V0.8_20140611.pdf
(http://www.seeedstudio.com/wiki/File:PAJ7620U2_Datasheet_V0.8_20140611.pdf)
LibraryGrove-Guesture(https://github.com/Seeed-Studio/Gesture_PAJ7620)
Retrievedfrom"http://www.seeedstudio.com/wiki/index.php?title=Grove_-
_Gesture_v1.0&oldid=106495"
Categories: Sensor Grove
Thispagewaslastmodifiedon23July2015,at06:59.
Thispagehasbeenaccessed5,527times.
This manual suits for next models
1
Table of contents
Other seeed studio Computer Hardware manuals
Popular Computer Hardware manuals by other brands

Mellanox Technologies
Mellanox Technologies MCX454A-FCAT user manual

aci
aci AFP Series Installation & operation instructions

AXIOMTEK
AXIOMTEK CAPA13S Series user manual

MicroBoards Technology
MicroBoards Technology NX1-1000 Specification sheet

Award
Award ECX810 user manual

Gigabyte
Gigabyte MC13-LE0 user manual