SEN0202

SampleCode
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 {
25 switch(cmd)
26 {
27 case GI_FLICK_R:
28 Serial.println("RIGHT");
29 break;
30 case GI_FLICK_L:
31 Serial.println("LEFT");
32 break;
33 case GI_FLICK_D:
34 Serial.println("DOWN");
35 break;
36 case GI_FLICK_U:
37 Serial.println("UP");
38 break;
39 case GI_AIRWHEEL_CW://Clockwise in circles
40 Serial.println("CW");
41 break;
42 case GI_AIRWHEEL_CCW://Counterclockwise circles
43 Serial.println("CCW");
44 break;
45
46 default: break;
47 }
48 }
49 }
50 else {};
51 }
Results
Use your hand to move up and down or clockwise and counterclockwise, the serial port will output
the corresponding string.
FAQ
For more questions or interesting projects, you can Visit the forum
Powered By DFRobot © 2008-2017

SEN0202

Mfr. #:
Manufacturer:
DFRobot
Description:
Distance Sensor Modules 3D Gesture Sensor (Mini) For Arduino
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet