pammie Posted May 28, 2013 Report Share Posted May 28, 2013 Hello, I connected 2 MPU6050's and 2 MMA8452's to a Arduino Fio. I'm using the DMP for the 6050's. Altering the example code for the MMA8452 to adress them at different adresses was not that difficult. I adapted the functions to pass the device adress. The example code for the MPU6050 is a lot bigger and complexer so I was wondering how I could pass the device address as a global variable. Tried some, but compiler keeps on protesting. Has someone experience with this?? Greetings, Pamela Quote Link to comment Share on other sites More sharing options...
pammie Posted May 28, 2013 Author Report Share Posted May 28, 2013 Just an addition.. First I tried to use the specific address constructor in mpu6050.cpp In my sketch it says: .... MPU6050 mpu; ..... mpu.MPU6050(MPU6050_ADDRESS_AD0_HIGH); // actions for MPU at high address .... mpu.MPU6050(MPU6050_ADDRESS_AD0_LOW); // actions for MPU at low address .... Quote Link to comment Share on other sites More sharing options...
Jeff Rowberg Posted May 28, 2013 Report Share Posted May 28, 2013 Hi pammie, This would be much easier if you create two instances of the device: MPU6050 mpu1(MPU6050_ADDRESS_AD0_LOW); MPU6050 mpu2(MPU6050_ADDRESS_AD0_HIGH); Then simply use them as independent objects. The device constructor is meant to take the slave address as an optional parameter for this purpose. Quote Link to comment Share on other sites More sharing options...
pammie Posted May 28, 2013 Author Report Share Posted May 28, 2013 Hai Jeff, that is a nice solution, thanks, greetings, Pamela Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.