Introduction
The DFRobot 3D gesture sensor is an interactive sensor that integrates 3D gesture recognition and motion tracking. This sensor can be used to detect clockwise/counterclockwise rotation and movement directions. It is designed based on Microchip patent GestIC® technology with electric near field sensing technology, including 3D gesture input sensing system and advanced 3D signal processing unit. And its effective detection range is 0-10cm. This sensor can be applied to various interactive art projects. Just think about it, with a wave of your hands, the lamp turns on, music turns up. Everything is at your fingertips!
Specification
- Operating Voltage: 3.3~5 V
- Interface Type: I2C
- I2C Address: 0×42
- Gesture Detection Range: 5 cm
- Distance Induction Range: 10 cm
- Dimensions : 72 × 54 mm / 2.83 × 2.12"
- Operating Temperature: - 20 °C ~ + 85 °C
- Spatial Resolution: 150 dpi
Board Overview
Num | Label | Description |
---|---|---|
1 | GND | DND |
2 | VCC | VCC(5 V) |
3 | MCLR | Sensor Reset(Low Level On) |
4 | SCL | I2C clock signal |
5 | SDA | I2C data signal |
6 | D | Digital IO |
Sensor address: 0×42 |
Tutorial
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- 3D Gesture Sensor Mini x 1
- Jumper wires
- Software
- Arduino IDE
- Download and install the 3D Gesture Sensor mini Library. (About how to install the library?)
Connection Diagram
Sample Code
- This code will recognize the direction of gestures: up, down, left, right, clockwise and counterclockwise
/*!
* @file gesture.ino
* @brief gesture recognition, it can be up-->down,down-->up,left-->right,right-->left,Circle clockwise,Circle counterclockwise.
* @n Hardware Connections:
* @n HOST Pin SENSOR PIN Function
* @n GND GND Ground
* @n 3.3V-5V VCC Power
* @n SCL SCL I2C Clock
* @n SDA SDA I2C Data
* @n DPin D Transfer Status Line
* @n MCLRPin MCLR reset
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-09-18
* @url https://github.com/DFRobot/DFRobot_MGC3130
*/
#include <DFRobot_MGC3130.h>
//the following pins are recommended, can be customized by the users (pins with input and output functions are required)
#if defined(ESP32) || defined(ESP8266)
uint8_t DPin= D9;
uint8_t MCLRPin= D3;
#elif defined(ARDUINO_SAM_ZERO)
uint8_t DPin= 6;
uint8_t MCLRPin= 7;
#else
uint8_t DPin= 8;
uint8_t MCLRPin= 9;
#endif
DFRobot_MGC3130 myGesture(DPin,MCLRPin);
void setup()
{
Serial.begin(115200);
/**
* initialization function,return true if initialization succeeds, and false if initialization fails
*/
while(!myGesture.begin()){
Serial.println("begin error! Please check whether the connection is correct");
delay(100);
};
Serial.println("begin success!!!");
/**
* turn off AirWheel function,returning -1 means the setup fails, and 0 means the setup succeeds
*/
while(myGesture.disableAirWheel()!=0){
delay(100);
}
/**
* enable gesture recognition function, returning -1 means the setup fails, and 0 means the setup succeeds
*/
while(myGesture.enableGestures()!=0){
delay(100);
}
Serial.println("config success!!!");
}
void loop()
{
/**
* get the sensor data
*/
myGesture.sensorDataRecv();
/**
* get gesture information, gesture information:eFilckR/eFilckL/eFilckU/eFilckD/eCircleClockwise/eCircleCounterclockwise
*/
switch(myGesture.getGestureInfo()){
case myGesture.eFilckR:
Serial.println("Flick Left to Right");
break;
case myGesture.eFilckL:
Serial.println("Flick Right to Left");
break;
case myGesture.eFilckU:
Serial.println("Flick Down to Up");
break;
case myGesture.eFilckD:
Serial.println("Flick Up to Down");
break;
case myGesture.eCircleClockwise:
Serial.println("Circle clockwise");
break;
case myGesture.eCircleCounterclockwise:
Serial.println("Circle counterclockwise");
break;
default:
break;
}
}
Results
When you use your hand to move up and down or clockwise and counterclockwise, the serial port will output the corresponding string.
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.