Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Arduino Hand Gestur...
 
Share:
Notifications
Clear all

[Solved] Arduino Hand Gesture Remote for Android

11 Posts
2 Users
1 Reactions
1,335 Views
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Greeting,

I am new to Arduino try to work on this mini project.   I been watching some Arduino youtube videos for dummies kind of understand the basic but this mini project is way out of my league so I wonder if anyone can give me a hand here.  I have the Beetle Leonardo atmega32u4 board solider with Paj7620 modulo for hand gesture.  So further I was able to upload the Paj7620 code to read my hand gestures.

I been trying to follow this Arduino Leonardo Remote Control guide for Windows and Android.  Can anyone help me with combining the Paj7620 code with this remote control code?

I just want the commands for Play,pause/volume up/volume down/Next/Previous.

https://github.com/playfultechnology/arduino-gesture-recogniser

https://www.stefanjones.ca/blog/arduino-leonardo-remote-multimedia-keys/

Thanks in advance.

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2785
 

Well, I have zero experience with gesture recognition - but I do appreciate you mentioning it here.
I was not aware there was a module for that. Cool!

So when I look at the Gesture recognition code, then I'd say we do calls to the multimedia keys functions in the switch..case.. loop.

/**
 * Demonstration of PAJ7620 Gesture Recogniser module
 */

// INCLUDES
// Arduino Wire library is for communicating with any I2C device
#include <Wire.h>
// PAJ7620 library, based on datasheet as described at 
//  https://www.epsglobal.com/Media-Library/EPSGlobal/Products/files/pixart/PAJ7620F2.pdf?ext=.pdf 
#include "src/PAJ7620/paj7620.h"

void setup() {
  // Initialise serial connection to display results
	Serial.begin(9600);

  // Initialise the sensor
  int error = paj7620Init();
	if(error) {
    Serial.print(F("Initialisation error code: "));
    Serial.println(error);
	}
	else {
		Serial.println(F("Ready!"));
	}
}

void loop() {
  // Create a variable to hold the value of any gesture recognised
	byte gesture;
  // Error variable holds any error code
	int error;
  // Read Reg 0x43 of Bank 0 to get result of any recognised gesture, and store in 'gesture' variable
	error = paj7620ReadReg(0x43, 1, &gesture);
 
	if(!error) {
		switch (gesture) {
			case GES_RIGHT_FLAG:
			  Serial.println(F("Right"));          
				break;
			case GES_LEFT_FLAG: 
				Serial.println(F("Left"));         
				break;
			case GES_UP_FLAG:
				Serial.println(F("Up"));        
				break;
			case GES_DOWN_FLAG:
				Serial.println(F("Down"));         
				break;
			case GES_FORWARD_FLAG:
				Serial.println(F("Forward"));
				break;
			case GES_BACKWARD_FLAG:		  
				Serial.println(F("Backward"));
				break;
      // Library also defines GES_CLOCKWISE_FLAG GES_COUNT_CLOCKWISE_FLAG and GES_WAVE_FLAG, but I found these unreliable
			default:
				break;
		}
	}
 else {
    Serial.print(F("Error code: "));
    Serial.println(error);
 }
  // Introduce small delay before next polling the sensor 
  delay(100);
}

 

When looking at the Multimedia Remote control stuff, then you will have to modify a few standard files (USBAPI.h and HID.cpp) to get additional functions for the remote class.

Once you've done that and declared a variable to be of the type class "remote", you can do calls like myRemote.increase() (=volume), myRemote.decrease(), etc.

remote myRemote;

...

void loop() {
 
  ...

   switch (gesture) {
     case GES_RIGHT_FLAG:
       ...
     case GES_UP_FLAG:
       myRemote.increase(); // up volume        
       break;
     case GES_DOWN_FLAG:
       myRemote.decrease(); // down volume   
       break;
       ...
     default:
       break;
   }

   ...

} 

 

Hope this helps ...

 

 

Note: Personally, I do not like modifying standard files. Not to mention: classes can use inheritance, if I'm not mistaken, and these modifications therefore do not need to be done by modifying official libs) - but there may be a legit reason why this is done by the developer.
On top of that, using a infrared LED could do the trick (see this AdaFruit article).


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans After spending an hour reading your post.  I kind of understood what needs to be done but for me knowing nothing about coding is kind of hard to execute.  Appreciated your help.

This is a single project I want to do for an Android device but this too much learning for something I want to do for one time.   

Are there anyone I can pay them to help me do the programming? 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2785
 

To be honest: I don't know if you'll find anyone here that can do this for you.
I for one would not have the equipment. For example: I do not have an Android phone and I do not have the gesture model.

You could however try Fiverr and see if they have people available for this?
Projects there start at $5/project ... but the price goes up of course as the project gets more complex.

I've used them before for drawing graphics (they pretty much offer anything you can think of).


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

I finally got it working long story short. I posted my project on freelancer few people ping me but after I awarded them my project they decline without a reason possible my offer too low.   I fed up with this, seem no way out I had to do it the old fashion way.   I started google/youtube similer project like puzzle pieces, finally I got all the pieces together. 

After I got everything working there is one big problem.  I uploaded the code and test everything working.  Re-plug the USB stop working, I had to upload the code again to make it work.  Is this a hardware or coding problem?

 

#include 
#include 
#include 
#include 

#define MEDIA_FAST_FORWARD 0xB3 
#define MEDIA_REWIND 0xB4 
#define MEDIA_NEXT 0xB5 
#define MEDIA_PREVIOUS 0xB6 
#define MEDIA_STOP 0xB7 
#define MEDIA_PLAY_PAUSE 0xCD 
#define MEDIA_VOLUME_MUTE 0xE2 
#define MEDIA_VOLUME_UP 0xE9 
#define MEDIA_VOLUME_DOWN 0xEA 

#define GES_REACTION_TIME    300
#define GES_ENTRY_TIME      400 
#define GES_QUIT_TIME     400

void setup()
{
  uint8_t error = 0;

  Serial.begin(9600);
  error = paj7620Init();
  if (error) 
  {
    Serial.print("INIT ERROR,CODE:");
    Serial.println(error);
  }
  else
  {
    Serial.println("INIT OK");
  }
  Serial.println("Start Controlling Media with Gesturesn");
}

void loop()
{
  uint8_t data = 0, data1 = 0, error;
  
  error = paj7620ReadReg(0x43, 1, &data); 
  if (!error) 
  {
    switch (data)   
    {
      case GES_RIGHT_FLAG:
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
          Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
          Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else
        {

          Serial.println("Previous");
          Consumer.write(MEDIA_PREVIOUS);
          delay(500);
        }          
        break;
      case GES_LEFT_FLAG: 
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
          Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
         Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else
        {
         Serial.println("Next");
         Consumer.write(MEDIA_NEXT);
         delay(500);
        }          
        break;
      case GES_UP_FLAG:
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
          Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
        Serial.println("Mute/No Mute");
        Consumer.write(MEDIA_VOLUME_MUTE);
        delay(GES_QUIT_TIME);
        }
        else
        {
          Serial.println("PLAY_PAUSE");
          Consumer.write(MEDIA_PLAY_PAUSE);
          delay(500);
        }          
        break;
      case GES_DOWN_FLAG:
        delay(GES_ENTRY_TIME);
        paj7620ReadReg(0x43, 1, &data);
        if(data == GES_FORWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
          Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else if(data == GES_BACKWARD_FLAG) 
        {
          Serial.println("Mute/No Mute");
         Consumer.write(MEDIA_VOLUME_MUTE);
          delay(GES_QUIT_TIME);
        }
        else
        {
          Serial.println("STOP");
          Consumer.write(MEDIA_STOP);
          delay(500);
        }          
        break;
      case GES_FORWARD_FLAG:
        Serial.println("Mute/No Mute");
        Consumer.write(MEDIA_VOLUME_MUTE);
        delay(GES_QUIT_TIME);
        break;
      case GES_BACKWARD_FLAG:     
        Serial.println("Mute/No Mute");
       Consumer.write(MEDIA_VOLUME_MUTE);
        delay(GES_QUIT_TIME);
        break;
      case GES_CLOCKWISE_FLAG:
        Serial.println("Volume Up");
        Consumer.write(MEDIA_VOLUME_UP);
        delay(100);
        break;
      case GES_COUNT_CLOCKWISE_FLAG:
        Serial.println("Volume Down");
       Consumer.write(MEDIA_VOLUME_DOWN);
       delay(100);

        break;  
      default:
        paj7620ReadReg(0x44, 1, &data1);
        if (data1 == GES_WAVE_FLAG) 
        {
          Serial.println("Nothing Assigned");
        }
        break;
    }
  }
  delay(100);
}
This post was modified 2 years ago 2 times by Anonymous

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2785
 
Posted by: @navawong

Re-plug the USB stop working, I had to upload the code again to make it work.  Is this a hardware or coding problem?

Do you mean: Arduino connected to PC, upload sketch, and all works.
But once you disconnect from the PC, the Arduino it stops working?

I would have to guess this is a hardware related issue, but I'm not quite sure I understand when it fails.
As far as I can see, I doubt this to be software related.


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans Yes, upload sketch all works.  Disconnect from PC Arduino stop working.  

I just did a blink sketch upload from the example.   The LED start blinking after upload.  re-connect usb to PC few times.  The LED blinks every time I connect to PC.  I assume possible not hardware? 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2785
 

That's strange for sure ... does this happen when nothing is connect to the Arduino (sensors and such)?
I guess I do not have a clear picture how things are wired.


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

I figured the problem is the sensors.  I upload the sensor factory code for the gestures, same problem even I had it plug-in the computer 10min+ the sensors will start spamming "transmission error".  I bought 2 different version of this sensors both same problem.  I hate to say I have officially hit a dead end.  My project has to end. :(

Thanks for your all your help @Hans.


   
Hans reacted
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2785
 
Posted by: @flori22052003

Hi i have a problem with every program that i wrote its shows this message

Sketch uses 204498 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13416 bytes (4%) of dynamic memory, leaving 314264 bytes for local variables. Maximum is 327680 bytes.

Hi Flori - no hard feelings, but could you please start a new topic with your question?
Conversation hijacking is not proper netiquette ... 😉 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2785
 
Posted by: @navawong

I hate to say I have officially hit a dead end.  My project has to end. :(

Sorry to hear that ... 😞 


   
ReplyQuote
Share: