[solved] MPU6050 Library Include Error

This is totally confusing me - I'm trying to use the MPU6050 library to send gyroscope/accelerometer data via an Xbee to another Arduino. I added the MPU6050_DMP6 example file to my project so that it's a tab, and I made it a .cpp file so I could include it in my main program loop. I run the MPU6050 program loop whenever I want a new gyro/accel reading, and then I access the updated variables from the main program loop. The program won't compile because the compiler can't find the libraries that the .cpp file references. I've looked all over the place for a solution - I've tried including the libraries in the main program loop, but then the compiler goes crazy with errors.

Here's the include line in the main program:

#include "MPU6050_DMP6.cpp";

Attached is the MPU6050_DMP6.cpp file and the error that these two files throw - you can see the tab setup there.

Any help is much appreciated.

MPU6050_DMP6.cpp (16 KB)

#include "MPU6050_DMP6.cpp";Why are you trying to include a .cpp file ? Make it into a .ino file and put it in the same folder as your main program file and it will be compiled along with it and will appear on its own tab in the IDE.

That's what I originally did, but I couldn't access any of the variables in the other file. When I changed it to a .cpp file, I was able to access the variables when I included it in the main file. Is there some way to access the variables when the included file is a .ino file?

Never mind, I got it to work. I declared the variables I wanted to use using "extern", and I changed the other file from .cpp to .ino. Thanks for your help.