icon

Grove Smart IR Gesture Sensor (PAJ7660) Arduino Project

 Тoday I received the package I ordered from Seed Studio , and it contains the Grove smart IR Gesture sensor. The product is nicely packaged and comes with a basic information sheet. 
 

 This is a relatively new module, and this time I will try to make a practical device that will present its possibilities with the help of a microcontroller. During testing and development I will use utilities, libraries, and instructions from the Seed Studio site
 

As for microcontrollers, I plan to work with an Arduino Nano. Otherwise, the Gesture sensor module on the back side has a microswitch with 4 units, with which combinations can be changed the method of communication between I2C, SPI, and USB mode.
 

 The fastest and easiest way to test the sensor and basic functions is using the provided Windows application Gesture Demo. 
 

  For this purpose, the module should be set in USB mode, which means that the four microswitches should be in the OFF position. On the front of the sensor, in the upper left corner, there is a small human shape. If you see the figure standing upright, then you have placed it in the correct position.
 

  Now we need to connect the Grove Gesture Sensor to PC, start Application , and click on RUN button in the top left corner of the software and then select Gesture mode to see the results in real time. 
  Next, I present to you a way to make an independent device with the help of an Arduino microcontroller. This is the simplest example that will show the recognized gestures on the LCD display in text form, and at the same time will turn on the corresponding LED. LEDs can be replaced by relays that control a process, or execute another command or perform a function according to the user's needs. In a word, basically with this simple code, and with minimal modifications we can make complex functional devices. Otherwise the basic code is also taken from the Seed Studio site indicated above in the text. Writing code is not my specialty, so I'm sure it could be made much simpler, but the most important thing is that it works flawlessly. If you have knowledge, you can freely modify and simplify it.
 

      The whole device is very simple and contains only a few components:
- Arduino microcontroller
- 16x2 characters I2C LCD Display
- 5 LEDs with suitable resistors for current control
- Buzzer
- and Grove Smart IR Gesture Sensor from Seed Studio

   First we will do a finger test, where depending on the number of detected fingers, the appropriate number of LEDs are activated. Next is Swipe, which detects the direction of hand movement. For example, in this way we can change pictures in a photo album, programs on TV, or songs in a playlist.  And this time, just one more test, which I think is the most interesting, and that is clockwise and counterclockwise rotation. As you can see on the video, the executed commands are constantly displayed on the LCD Display.
 And finally a short conclusion:
  This little module is an intelligent gesture recognition device equipped with an infrared camera sensor and applied AI algorithm. It can detect over 15 gestures with wide detection while supporting both IIC and SPI communication. In this video, I have presented the simplest way of controlling the module, thus giving you the opportunity to develop more ideas yourself and make a device according to your needs.Otherwise, you can get the module in the Seed Studio store at a really affordable price, and the address is given below in the text.

CODE
#include "Gesture.h"
#include  <Wire.h>
#include  <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);
 
pag7660 Gesture; // Combined mode is used by default

void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);  
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  
    Serial.begin(9600);
    tone(10, 500, 1000);
    
       while(!Serial) {
        delay(100);
    }
    Serial.println("\nPAG7660 TEST DEMO: Gesture combined mode.");
    
    if(Gesture.init()) {
        Serial.println("PAG7660 initialization success");
       lcd.setCursor(5,0);
  lcd.print("PAG7660");    
   lcd.setCursor(1,1);
  lcd.print("Init. success");
  
  delay(2000);
    } else {
        Serial.println("PAG7660 initialization failed");
    }
    Serial.println("Please input your gestures:\n");
   lcd.clear();
   lcd.setCursor(1,0);
  lcd.print("Input Gesture:");
}

void loop() {
    pag7660_gesture_t result;
    if (Gesture.getResult(result)) {
        printResultCombinedMode(result);
    }
    delay(100);
}

void printResultCombinedMode(const pag7660_gesture_t& result) {
    const char *cursor_str[] = {
        NULL,
        "Tap",
        "Grab",
        "Pinch",
    };
    switch (result.type) {
    case 0:
        switch (result.cursor.type) {
        case 1:
        case 2:
        case 3:
            if (result.cursor.select)
                Serial.println(cursor_str[result.cursor.type]);
            break;
        default:
            break;
        }
        break;
    case 1:
        
    case 2:
     
    case 3:
    case 4:
    case 5:
        Serial.print(result.type);
        Serial.println("-finger");
         
          lcd.setCursor(1,1);
          lcd.print(result.type);
          lcd.print(" - finger   ");

          if (result.type <= 1) {
         digitalWrite(2, HIGH); 
         digitalWrite(3,LOW); 
         digitalWrite(4,LOW);
         digitalWrite(5,LOW);
         digitalWrite(6,LOW); 
          }
      
          if (result.type >1  && result.type<=2 ) {
         digitalWrite(2, HIGH); 
         digitalWrite(3,HIGH); 
         digitalWrite(4,LOW);
         digitalWrite(5,LOW);
         digitalWrite(6,LOW); 
          }
       
         if (result.type >2  && result.type<=3 ) {
         digitalWrite(2, HIGH); 
         digitalWrite(3,HIGH); 
         digitalWrite(4,HIGH);
         digitalWrite(5,LOW);
         digitalWrite(6,LOW); 
          }
         if (result.type >3  && result.type<=4 ) {
         digitalWrite(2, HIGH); 
         digitalWrite(3,HIGH); 
         digitalWrite(4,HIGH);
         digitalWrite(5,HIGH);
         digitalWrite(6,LOW); 
          }
          if (result.type >4  && result.type<=5 ) {
         digitalWrite(2, HIGH); 
         digitalWrite(3,HIGH); 
         digitalWrite(4,HIGH);
         digitalWrite(5,HIGH);
         digitalWrite(6,HIGH); 
          }
    break;
      
    case 6:
        Serial.print("Rotate Right ");
        Serial.println(result.rotate);
        break;
    case 7:
        Serial.print("Rotate Left ");
        Serial.println(result.rotate);
        break;
    case 8:
    Serial.println("Swipe Left");
    lcd.setCursor(1,1);
    lcd.print("<-Swipe Left  "); 
     tone(10, 3000, 100);  
   digitalWrite(2, HIGH);  
   digitalWrite(3, HIGH);
   digitalWrite(4, LOW);  
   digitalWrite(5, LOW);  
   digitalWrite(6, LOW);  
   delay(1000);
   digitalWrite(2,LOW);  
   digitalWrite(3, LOW); 
   break;
   
    case 9:
        Serial.println("Swipe Right");

   lcd.setCursor(1,1);
   lcd.print("Swipe Right->"); 
  tone(10, 3000, 100);
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
   digitalWrite(5, HIGH);  
   digitalWrite(6, HIGH); 
    delay(1000);
   digitalWrite(5,LOW);  
   digitalWrite(6, LOW);  
   
        break;
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
        Serial.print(result.type - 19 + 1);
        Serial.println("-finger push");
        break;
    default:
        break;
    }
    
}
License
All Rights
Reserved
licensBg
0