Comments (4)
I quickly changed one of the examples, it compiles but not tested with hardware (yet).
please give it a try. If it works for you I will add it to the library
//
// FILE: GY521_two_sensors.ino
// AUTHOR: Rob Tillaart
// PURPOSE: read angleX, angleY, angleZ from two sensors
#include "GY521.h"
GY521 sensor1(0x68);
GY521 sensor2(0x69);
uint32_t counter = 0;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println(__FILE__);
Serial.print("GY521_LIB_VERSION: ");
Serial.println(GY521_LIB_VERSION);
Wire.begin();
// INITIALIZE SENSOR 1
delay(100);
while (sensor1.wakeup() == false)
{
Serial.print(millis());
Serial.println("\tCould not connect to sensor1");
delay(1000);
}
sensor1.setAccelSensitivity(2); // 8g
sensor1.setGyroSensitivity(1); // 500 degrees/s
sensor1.setThrottle();
Serial.println("start...");
// set calibration values from calibration sketch.
sensor1.axe = 0.574;
sensor1.aye = -0.002;
sensor1.aze = -1.043;
sensor1.gxe = 10.702;
sensor1.gye = -6.436;
sensor1.gze = -0.676;
// INITIALIZE SENSOR 2
delay(100);
while (sensor2.wakeup() == false)
{
Serial.print(millis());
Serial.println("\tCould not connect to sensor2");
delay(1000);
}
sensor2.setAccelSensitivity(2); // 8g
sensor2.setGyroSensitivity(1); // 500 degrees/s
sensor2.setThrottle();
Serial.println("start...");
// set calibration values from calibration sketch.
sensor2.axe = 0.574;
sensor2.aye = -0.002;
sensor2.aze = -1.043;
sensor2.gxe = 10.702;
sensor2.gye = -6.436;
sensor2.gze = -0.676;
}
void loop()
{
// READ SENSOR 1
sensor1.read();
float x1 = sensor1.getAngleX();
float y1 = sensor1.getAngleY();
float z1 = sensor1.getAngleZ();
// READ SENSOR 2
sensor2.read();
float x2 = sensor1.getAngleX();
float y2 = sensor1.getAngleY();
float z2 = sensor1.getAngleZ();
// OPTIONAL TIME / NR
// Serial.print(millis);
// Serial.print('\t');
// Serial.print(counter);
// Serial.print('\t');
Serial.print(x1, 1);
Serial.print('\t');
Serial.print(y1, 1);
Serial.print('\t');
Serial.print(z1, 1);
Serial.print('\t');
Serial.print('\t');
Serial.print(x2, 1);
Serial.print('\t');
Serial.print(y2, 1);
Serial.print('\t');
Serial.print(z2, 1);
Serial.println();
counter++;
}
// -- END OF FILE --
from gy521.
example is also in develop branch - https://github.com/RobTillaart/GY521/tree/develop
from gy521.
Perfect! It works!
from gy521.
you're welcome!
from gy521.
Related Issues (20)
- Elaborate unit tests
- Examples use GetAngle instead of GetAccel HOT 2
- Enabling the interruptions HOT 6
- Calibration never zeros out HOT 7
- Add multiWire support
- improve performance + precision
- improve precision HOT 1
- swire support HOT 27
- Invalid data without Reset while initializing the begin HOT 9
- version number incorrect in .h and .cpp (minor)
- getting position from distance = acceleration * time HOT 7
- Raw data HOT 1
- getYaw, getPitch and getRoll go past 360 degrees HOT 19
- small bugfix in readCalibration HOT 3
- Shifted pitch and yaw measurement HOT 19
- why when I run the GY521_pitch_roll_yaw example code, all the numbers slowly increase 0 -> 359 -> 0? HOT 22
- missing ; in .h file HOT 2
- Bad results with Teensy 3.2 HOT 4
- getRegister can return an error which is not handled properly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gy521.