- Mon Apr 10, 2017 10:38 pm
#194332
Hello,
I'm making a two-player game, where each player uses a controller with a SparkFun ADXL345 accelerometer to control their character on screen. I have everything working well when connecting a single ADXL345 sensor for one of the players. The sensor is connected using I2C.
I know there is an alternate address mode where I can tie the SDO pin to VCC instead of GND. However, how do I use the SparkFun_ADXL345.h library with multiple sensors? Could you give me an example?
I can see the device being initiated as: ADXL345 adxl = ADXL345();
Then, the raw values are read as such: adel.readAccel (&x, &y, &z);
How do I do the same with a second ADXL345 sensor?
Thank you in advance,
N.
I'm making a two-player game, where each player uses a controller with a SparkFun ADXL345 accelerometer to control their character on screen. I have everything working well when connecting a single ADXL345 sensor for one of the players. The sensor is connected using I2C.
I know there is an alternate address mode where I can tie the SDO pin to VCC instead of GND. However, how do I use the SparkFun_ADXL345.h library with multiple sensors? Could you give me an example?
I can see the device being initiated as: ADXL345 adxl = ADXL345();
Then, the raw values are read as such: adel.readAccel (&x, &y, &z);
How do I do the same with a second ADXL345 sensor?
Thank you in advance,
N.