Combining two sketches

I have an MPU 6050 and a BMP 180 and I need help combining both of the codes. I have checked and each of the codes work individually however when I try and merge them together, it gives me the error that "bmp" was not declared in this scope, even though they work fine by themselves. My two codes and the combined code are attached. Thank you in advance

Working_BMP_Code.ino (1.03 KB)

Working_MPU_code.ino (7.68 KB)

Combined_code.ino (4.4 KB)

(deleted)

I did that yet the same error still shows up

(deleted)

Thank you for your quick response; I must add that I am quite new to all of this but in my original posting I added three files, the one that says combined code is what I am using and all that I did was double slash Adafruit_BMP085 bmp; from the document. I did not change anything else. Hopefully this helps

Hope springs eternal!

Please post your code inline with the </> code tags.
Read the sticky topic How to Post in the forum.

It makes it infinitely easier for people to help...
for example, I haven’t even looked at your sketch until I get home to a PC

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

Sebnah:
all that I did was double slash Adafruit_BMP085 bmp; from the document.

That's not what spycatcher2k said though:

spycatcher2k:

Adafruit_BMP085 bmp;

Move this line out of the function.

Look at your working code- that line isn't in a function, where you have it just above setup. In your new code, that line's in a function. spycatcher2k asked you to move it out of the function, not zap it from the document.

here is your mistake. you have a function.

// example of a function

void setup ()
{
stuff goes here
} < = that is the end of the SETUP function

then in your sketch, you have a combined sketch function

void dmpDataReady()
{
mpuInterrupt = true;
Adafruit_BMP085 bmp;
} < = that is the closing bracket on dmpDataReady() function

what you did, as SpyCatcher told you, is that you put a line in that function that is required for the rest of your sketch, but it is hidden inside of a function.

take it out and move it before the function.

as a note, you might want to label your functions

void dmpDataReady() { // +++++++++++++ dmpDataReady ++++++
mpuInterrupt = true;
Adafruit_BMP085 bmp;
} // =============== end dmpDataReady ========

I use the +++++ to show the start and the ====== to show the end.

as a note, it would be good of you to do this,
then post your combined code again
and, tell us if this solved your problem.

and if it does not, then copy your error message and post that with your code.