KS0458 Keyestudio PAJ7620 Gesture Recognition Sensor Module

From Keyestudio Wiki
Jump to navigation Jump to search


Keyestudio PAJ7620 Gesture Recognition Sensor Module(Black and Eco-friendly)


Overview

Keyestudio PAJ7620 gesture recognition sensor module mainly integrates PAJ7620 chip. It integrates gesture recognition and I2C interface.
This gesture sensor can recognize nine gestures, including moving Up, Down, Left, Right, Forward, Backward, Clockwise, anti-clockwise, wave.
In order to fix on other devices, the module comes with a positioning holes with a diameter of 3mm.
This gesture sensor can be used to detect clockwise/counterclockwise rotation and movement directions.
This gesture sensor can be applied to various interactive projects.


Technical Details

  • Working voltage: DC 5V
  • Working current: 50mA
  • Maximum power: 0.5W
  • Detection distance: 10cm (maximum)
  • Gesture speed: 60°/S - 600°/S (normal mode); 60°/S - 1200°/S (game mode)
  • Ambient light immunity: <100k Lux
  • I2C communication speed: 400kbit/s
  • Working temperature: -25 ~ +65℃
  • Interface: 5pin header (2.54mm pitch)
  • Fixing hole diameter: 3mm
  • Dimensions: 35mm*20mm*8mm
  • Environmental attributes: ROHS


Connection


thumb


Test Code

Note: before upload the code, don’t forget to place the necessary library into Arduino IDE library directory.

#include <Wire.h>
#include "paj7620.h"

/* 
Notice: When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s). 
        You also can adjust the reaction time according to the actual circumstance.
*/
#define GES_REACTION_TIME		500				// You can adjust the reaction time according to the actual circumstance.
#define GES_ENTRY_TIME			800				// When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s). 
#define GES_QUIT_TIME			1000

void setup()
{
	uint8_t error = 0;

	Serial.begin(9600);
	Serial.println("\nPAJ7620U2 TEST DEMO: Recognize 9 gestures.");

	error = paj7620Init();			// initialize Paj7620 registers
	if (error) 
	{
		Serial.print("INIT ERROR,CODE:");
		Serial.println(error);
	}
	else
	{
		Serial.println("INIT OK");
	}
	Serial.println("Please input your gestures:\n");
}



	
void loop()
{
	uint8_t data = 0, data1 = 0, error;
	
	error = paj7620ReadReg(0x43, 1, &data);				// Read Bank_0_Reg_0x43/0x44 for gesture result.
	if (!error) 
	{
		switch (data) 									// When different gestures be detected, the variable 'data' will be set to different values by paj7620ReadReg(0x43, 1, &data).
		{
			case GES_RIGHT_FLAG:
				delay(GES_ENTRY_TIME);
				paj7620ReadReg(0x43, 1, &data);
				if(data == GES_FORWARD_FLAG) 
				{
					Serial.println("Forward");
					delay(GES_QUIT_TIME);
				}
				else if(data == GES_BACKWARD_FLAG) 
				{
					Serial.println("Backward");
					delay(GES_QUIT_TIME);
				}
				else
				{
					Serial.println("Right");
				}          
				break;
			case GES_LEFT_FLAG: 
				delay(GES_ENTRY_TIME);
				paj7620ReadReg(0x43, 1, &data);
				if(data == GES_FORWARD_FLAG) 
				{
					Serial.println("Forward");
					delay(GES_QUIT_TIME);
				}
else if(data == GES_BACKWARD_FLAG) 
				{
					Serial.println("Backward");
					delay(GES_QUIT_TIME);
				}
				else
				{
					Serial.println("Left");
				}          
				break;
			case GES_UP_FLAG:
				delay(GES_ENTRY_TIME);
				paj7620ReadReg(0x43, 1, &data);
				if(data == GES_FORWARD_FLAG) 
				{
					Serial.println("Forward");
					delay(GES_QUIT_TIME);
				}
				else if(data == GES_BACKWARD_FLAG) 
				{
					Serial.println("Backward");
					delay(GES_QUIT_TIME);
				}
				else
				{
					Serial.println("Up");
				}          
				break;
			case GES_DOWN_FLAG:
				delay(GES_ENTRY_TIME);
				paj7620ReadReg(0x43, 1, &data);
if(data == GES_FORWARD_FLAG) 
				{
					Serial.println("Forward");
					delay(GES_QUIT_TIME);
				}
				else if(data == GES_BACKWARD_FLAG) 
				{
					Serial.println("Backward");
					delay(GES_QUIT_TIME);
				}
				else
				{
					Serial.println("Down");
				}          
				break;
			case GES_FORWARD_FLAG:
				Serial.println("Forward");
				delay(GES_QUIT_TIME);
				break;
			case GES_BACKWARD_FLAG:		  
				Serial.println("Backward");
				delay(GES_QUIT_TIME);
				break;
			case GES_CLOCKWISE_FLAG:
				Serial.println("Clockwise");
				break;
			case GES_COUNT_CLOCKWISE_FLAG:
				Serial.println("anti-clockwise");
				break;  
			default:
				paj7620ReadReg(0x44, 1, &data1);
				if (data1 == GES_WAVE_FLAG) 
				{
					Serial.println("wave");
				}
				break;
		}}delay(100);}



Test Result

Done uploading the code, open the serial monitor and set the baud rate to 9600.
The monitor window will print out the English letters of a gesture.
Put the gesture module face up, move Up, Down, Left, Right, Forward, Backward, Clockwise, anti-clockwise, wave.
thumb



Resource

  • Download all the relevant info from the link:

https://fs.keyestudio.com/KS0458



Buy from

  • [ Official Website]
  • [ Shop on Aliexpress ]