Hand Gesture Recognition Sensor (PAJ7620) © GPL3+

Add hand gestures to your Arduino projects (robots, HMI, lights, etc.).

  • 2,495 views
  • 2 comments
  • 10 respects

Components and supplies

About this project

Tutorial video if needed

Hello, and welcome, this fast tutorial is about the PAJ7620 hand gestures sensor, it permits your hand gestures to be detected by the Arduino board, and then you can use it to control lights, robots (cool stuff), HMI, games… using IR LED and optical CMOS array, it can detect up to 15 gestures.

This one costs around $2-3 only but is not efficient (as you can see in the video) as the thermal imaging arrays that can much detect complex gestures cost around $30-40.

The gestures that can be detected are: right, left, up, down, forward, backward, clockwise, counter-lockwise and waving. Those are the basic 9 then you can add right-left, left-right, up-down, down-up, forward-backward, backward-forward. (Check the video to know the differences).

There are two ways of detecting:

  • Near, which is on 5-15 cm distance with 60° angle
  • Far, on 15-30 cm distance with 30° angle

For this project I’m going to interface it with Arduino Uno board, and I’ll use a LCD i²c screen to show the gesture detected, using this method you can adapt it to whatever project you’re working on.

Parts

Test

The tests are straight forward, just plug and start moving your hands.

Overall the module performances are not bad for $2, sometimes it can be tricky when detecting the Forward gesture, you can check the code to actually find that it can be confused with other gestures, you can always modify the detection speed for all and for the forward and backward alone:

Also, make sure the module is on a flat surface, otherwise the clockwise and anti-clockwise gestures won’t be detected. Make sure you have enough space for you hand to move.

Code

PAJ7620_Gestures_LCD.inoArduino
The code that uses the LCD i²c, just to show you can adapt it to pretty much everything
/* This code works with PAJ7620 Hand gestures sensor and LCD ic screen
 * It shows the gestures detected on the LCD screen
 * Adapted from the Seeed PAJ7620 library examples
 * For more details check www.surtrtech.com
 */

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

#define I2C_ADDR 0x27 //I2C adress, you should use the code to scan the adress first (0x27) here
#define BACKLIGHT_PIN 3 // Declaring LCD Pins
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

#define GES_REACTION_TIME    500     
#define GES_ENTRY_TIME      800        
#define GES_QUIT_TIME     1000


LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup() {
  paj7620Init();
  
  lcd.begin (16,2);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH); //Lighting backlight
  
}

void printing(){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Gesture Sensor");
  lcd.setCursor(0,1);
}

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) 
        {
          printing();
          lcd.print("Forward");
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          printing();
          lcd.print("Backward");
          delay(GES_QUIT_TIME);
        }
        else
        {
          printing();
          lcd.print("Right");
        }          
        break;
      case GES_LEFT_FLAG: 
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          printing();
          lcd.print("Forward");
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          printing();
          lcd.print("Backward");
          delay(GES_QUIT_TIME);
        }
        else
        {
          printing();
          lcd.print("Left");
        }          
        break;
      case GES_UP_FLAG:
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          printing();
          lcd.print("Forward");
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          printing();
          lcd.print("Backward");
          delay(GES_QUIT_TIME);
        }
        else
        {
          printing();
          lcd.print("Up");
        }          
        break;
      case GES_DOWN_FLAG:
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          printing();
          lcd.print("Forward");
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          printing();
          lcd.print("Backward");
          delay(GES_QUIT_TIME);
        }
        else
        {
          printing();
          lcd.print("Down");
        }          
        break;
      case GES_FORWARD_FLAG:
        printing();
        lcd.print("Forward");
        delay(GES_QUIT_TIME);
        break;
      case GES_BACKWARD_FLAG: 
        printing();    
        lcd.print("Backward");
        delay(GES_QUIT_TIME);
        break;
      case GES_CLOCKWISE_FLAG:
        printing();
        lcd.print("Clockwise");
        break;
      case GES_COUNT_CLOCKWISE_FLAG:
        printing();
        lcd.print("anti-clockwise");
        break;  
      default:
        paj7620ReadReg(0x44, 1, &data1);
        if (data1 == GES_WAVE_FLAG) 
        {
          printing();
          lcd.print("wave");
        }
        break;
    }
  }
  
  delay(100);

}
LCD NewLiquidCrystal i²c library

Schematics

Wiring 1
Direct test and use
Wiring 1 mbggvvuba2
Wiring 2
Adding the LCD i²c
Wiring 2 aixnupaqeg

Comments

Similar projects you might like

Gesture Controlled Robotic Hand

Project tutorial by Rushabh Jain

  • 969 views
  • 0 comments
  • 6 respects

Gesture Controlled Robot Glove with Hall Effect Sensor

Project tutorial by Jithin Sanal

  • 2,320 views
  • 0 comments
  • 9 respects

Playing NFS By Hand Gesture Control

Project tutorial by Najad

  • 5,031 views
  • 3 comments
  • 25 respects

Gesture Recognition Using Accelerometer and ESP

Project tutorial by mellis

  • 42,108 views
  • 24 comments
  • 78 respects

LED Controlled by 3D Gesture Sensor

Project tutorial by HomeMadeGarbage

  • 6,896 views
  • 0 comments
  • 20 respects
Add projectSign up / Login