Servo matches up with a MPU6050 Gyro and Accelerator

Hello. I posted a library problem I was having with my code...and I fixed that because of you guys. Thanks

However.....I need a project or tutorial that I can use to control a servo (can be 2) with a MPU6050.

I've tried a few projects and none of them have worked :frowning:

If someone has done one of these projects..please post the tutorial you used that worked.

Thanks so much!

Ps: Thanks everyone for helping me solve the library problem :slight_smile:

Do you want to counter torque a servo in relation to the angle of MPU6050 tilt?

From the MPU you only need Ax and Ay to calculate angles of tilt, look it up on the internet.

Next you'll want to counter torque the servo in relation to MPU tilt.

Instead of degrees, I'd use micro seconds to torque the servos.

Basically:

If you got a 180 degree servo, using the servo library, you'll be able to torque from 500uS (0 degrees), to 2500uS ( 180 degrees). A total range of 2000u Seconds. or 11.11uS per degree, for full range torque. Don't forget this is basically.

Now you'd derive how many micro seconds you need to, in opposition, torque the servo to compensate for accelerometer derived tilt angle.

This above method works OK.

You may want to add in a complimentary low pass filter to use gyro information to smooth out the angle data. With a complimentary filter you'll need delta Time, For an Uno dt is best captured by using micros() and not millis().

Ok. I just want the servo to mirror the MPU6050. Can you please post a link that I can use...it would help if you have already tried it and it worked. :slight_smile:

An MPU6050 works in 3 dimensions. A servo can only move in 2 dimensions. So you're going to want to be a lot more definite about what you're really trying to achieve before you can find a project that already does whatever it really is.

Also it might help to post the best of the "few projects" that you've tried and explain what it does and then what it doesn't do that you need it to.

Steve

Ok...Here are the links I tried

This one was the most promising...but it was not woring!

Do you guys got any links?

"not woring" is not a very useful description of a problem. Does it compile? Does it do anything? If so exactly what does it do?

What was wrong with the maker.pro project? It looks reasonable to me but I don't have an MPU6050 handy to test it and I still don't know what EXACTLY you want yours to do.

Steve

Here...this is a more specific account of my problem Steve: (Its compiling but no doing anything at all)

https://forum.arduino.cc/index.php?topic=672707.0

Thanks for trying to help :slight_smile:

@arduino12456789

You were warned about cross posting.

Please take the next two days to read the following links.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum.

Bob.