I have been attempting to incorporate the MPU6050_DMP example into a program I have.
This program needs the angles that the gyroscope gives.
I'm not going to be pasting my code in here because it is far too massive. But this is more than enough info to understand what is going on:
I have tried to do the following from the MPU example program to my program:
- Copy paste all globals, headers etc. from MPU to my file
- Copy everything in MPU setup to my setup.
- Copy the loop of the MPU example into a function, I have called double gyro(), and I just simply added a single line for returning one value that I need. NO other modifications were made to the code.
With this, I thought I have all files, variables, etc., everything required by the MPU in setup, and then I can just call the 'loop' part of it to get the value of the gryoscope whenever needed.
Alternatively, I have tried what was advised in this post: https://forum.allaboutcircuits.com/threads/combining-two-arduino-sketches.123592/
However, none of these work, and I honestly have no reasoning as to why my first attempt (the 3 steps) doesn't work.
I have ensured that there is no overlap in any variables, functions etc.
Also, the MPU6050 does work when just using the example code alone. So wiring etc. is ok.
This is the exact MPU6050 example code I am using:
Is there a function version of MPU6050 code?
Is merging two arduino files more complicated then what I have assumed it to be?
Note that when I say doesn't work, it is just not returning anything.
Even if I do the following in my loop:
Nothing is printed to the Serial.