Makerming
Published © MIT

Gesture Control Hercules Mobile Robotic Platform - Arduino

A gesture control vehicle made by Seeedstudio Skeleton Bot - 4WD Hercules Mobile Robotic Platform. Having a lot of fun.

BeginnerFull instructions provided10 hours2,493

Things used in this project

Hardware components

Seeed Skeleton Bot - 4WD Hercules Mobile Robotic Platform
×1
UartSBee V4
Seeed UartSBee V4
×1
Seeed Hercules Dual 15A 6-20V Motor Controller
×1
Seeed Grove - Gesture Sensor(PAJ7620U2)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

ftdi_ft232_drive

Motor_Controller_Library

Schematics

Part Lists

Code

motorDriverDemo

C/C++
#include "motordriver_4wd.h"
#include <seeed_pwm.h>

void setup()
{
    MOTOR.init();
}

void loop()
{
    MOTOR.setSpeedDir1(30, DIRF);
    MOTOR.setSpeedDir2(30, DIRR);
    delay(8000);

    MOTOR.setStop1();
    MOTOR.setStop2();    
    delay(1000);
    
    MOTOR.setSpeedDir1(30, DIRR);
    MOTOR.setSpeedDir2(30, DIRF);
    delay(8000);

    MOTOR.setStop1();
    MOTOR.setStop2();    
    delay(1000);

    MOTOR.setSpeedDir(30, DIRR);
    MOTOR.setSpeedDir(30, DIRF);
    delay(8000);

    MOTOR.setStop1();
    MOTOR.setStop2();    
    delay(1000);

    
    MOTOR.setSpeedDir(30, DIRF);
    MOTOR.setSpeedDir(30, DIRR);
    delay(8000);

    MOTOR.setStop1();
    MOTOR.setStop2();    
    delay(1000);
}
/*********************************************************************************************************
 * END FILE
 *********************************************************************************************************/

Gesture_Control_Hercules_Mobile_Robotic_Platform.ino

C/C++
#include "motordriver_4wd.h"
#include <seeed_pwm.h>

#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    50       // You can adjust the reaction time according to the actual circumstance.
#define GES_ENTRY_TIME      80       // 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     10

void setup() {

  MOTOR.init();

  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() {
  // put your main code here, to run repeatedly:

  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");
             
    MOTOR.setSpeedDir1(50, DIRF);
    MOTOR.setSpeedDir2(50, DIRR);
    delay(300);
    
    MOTOR.setStop1();
    MOTOR.setStop2();    
    
        }          
        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");
          
    MOTOR.setSpeedDir1(50, DIRR);
    MOTOR.setSpeedDir2(50, DIRF);
    delay(300);
    
    MOTOR.setStop1();
    MOTOR.setStop2();    
          
          
        }          
        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");
          
    MOTOR.setSpeedDir(50, DIRF);
    MOTOR.setSpeedDir(50, DIRR);
    delay(300);

    MOTOR.setStop1();
    MOTOR.setStop2();    
    
        }          
        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");
          
    MOTOR.setSpeedDir(50, DIRR);
    MOTOR.setSpeedDir(50, DIRF);
    delay(300);
    
    MOTOR.setStop1();
    MOTOR.setStop2();    

        }          
        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);

}

Credits

Makerming

Makerming

3 projects • 2 followers
Maker, share one demo with you every week

Comments

Add projectSign up / Login