Mpu 6050 gesture help

Hello is anyone aware of any sketches that can be used to trigger gesture hand control over a output? I havent been able to find any sketches online,im looking for something along the lines of "if gyro sensor is blah then turn this led on,if its nlah blah then turn that light on" i havent been able to find a sketch like this if anyone can point me in the right direction i would be grateful :grin:

The sketch for testing a value or a series of values will be easy compared to the the problem of defining blah and nlah blah

Have you got a sketch that reads the values returned by the MPU6050 so that you can establish what to test for ?

Unforuntaly not,i just need one that can compare a range of different values in varying positions and i will add something like
" if (gyro value == right_angle & init_button == high){ digitialWrite(led_pin,HIGH);}"

But i am not equipt enough to write my own code on the matter but the make believe mini sketch above is kind of the parameter im looking for

Start by installing a library for the sensor and looking at the examples that come with it. There will usually be one that prints all of available data so that you can see what is returned when the sensor is in various positions and when it is moving

I have tried this but i have problems with the device reading the current value and the math used to convert the raw data to degrees

What exactly is "this" ?

Which library are you using and which example or examples have you tried ?

Mpu light and mpu6050 standard lib also the ada fruit gyro library also

Ive tried most sample sketches but it was just for interfacing and spitting out raw data via serial monitor

If you can see the raw data then that is a start

Now you need to decide exactly what you mean by blah and nlah blah. What exactly are you trying to detect and what would the raw data be for those conditions ?

So the goal would be for "blah" to be a global int and hold values that compare to a range of predetermined angles based off the position of y and x axis so blah would equal current position of hand,against a pretermined global int value that would determine the function of the microcontroller based on which value is present of the hand at the time of reading the values,my problem is not knowing how to code that or find a sketch on the interwebs that has the solution

It would not need to be global but the principle of what you describe sounds OK

If I were you I would set aside the project until you have got the basics under your belt such as how to compare a variable with a value or range of values and do something, even if it is only to print a message, when the value is in the range


void setup()
{
  Serial.begin(115200);
  for (int v = 0; v < 25; v++)
  {
    checkValue(v);
  }
}

void loop()
{
}

void checkValue(int value)
{
  Serial.print(value);
  if (value > 5 && value < 20)
  {
    Serial.println(" is in required range");
  }
  else
  {
    Serial.println(" is not in the required range");
  }
}
1 Like

Thanks i have the concept but i dont code enough for the syntax and everything to stay in my head for long,i will brush up on everything again,thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.