SampleCode
Click to download the library sample and library(Github). How to intall libraries?
https://github.com/DFRobot/DFRobot_Gesture
This code will recognize the direction of gestures: up, down, left, right, clockwise and
counterclockwise
1 #include <DFRobot_Gesture.h>
2 #include <Wire.h>
3
4 int testPin= 7;
5 unsigned char cmd;
6
7 DFRobot_Gesture myGesture;
8
9 void setup()
10 {
11 Wire.begin(); // join i2c bus (address optional for master)
12 Serial.begin(9600); // start serial for output
13 pinMode(testPin, INPUT);
14 Serial.write("3D Gesture sensor is now running....\r\n");
15 }
16
17 void loop()
18 {
19 if(digitalRead(testPin)==0)
20 {
21 myGesture.I2C1_MasterRead(md.buf,26,0x42); //The address is:0x42
22 cmd = myGesture.mgcProcMsg(); //process the message
23 if(cmd != GI_NOGESTURE )
24 {