GY-63_MS5611/libraries/GY521/examples/GY521_angle/GY521_angle.ino

75 lines
1.3 KiB
Arduino
Raw Normal View History

2022-07-27 06:42:05 -04:00
//
// FILE: GY521_angle.ino
// AUTHOR: Rob Tillaart
2023-01-27 07:07:04 -05:00
// PURPOSE: read angleX, angleY, angleZ
2022-07-27 06:42:05 -04:00
// DATE: 2022-06-06
#include "GY521.h"
GY521 sensor(0x68);
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();
delay(100);
while (sensor.wakeup() == false)
{
Serial.print(millis());
Serial.println("\tCould not connect to GY521");
delay(1000);
}
2023-01-27 07:07:04 -05:00
sensor.setAccelSensitivity(2); // 8g
sensor.setGyroSensitivity(1); // 500 degrees/s
2022-07-27 06:42:05 -04:00
sensor.setThrottle();
Serial.println("start...");
2023-01-27 07:07:04 -05:00
// set calibration values from calibration sketch.
2022-07-27 06:42:05 -04:00
sensor.axe = 0.574;
sensor.aye = -0.002;
sensor.aze = -1.043;
sensor.gxe = 10.702;
sensor.gye = -6.436;
sensor.gze = -0.676;
}
void loop()
{
sensor.read();
float x = sensor.getAngleX();
float y = sensor.getAngleY();
float z = sensor.getAngleZ();
if (counter % 10 == 0)
{
2023-01-27 07:07:04 -05:00
// Serial.println("\nCNT\tX\tY\tZ");
2022-07-27 06:42:05 -04:00
}
2023-01-27 07:07:04 -05:00
// Serial.print(counter);
// Serial.print('\t');
2022-07-27 06:42:05 -04:00
Serial.print(x, 1);
Serial.print('\t');
Serial.print(y, 1);
Serial.print('\t');
Serial.print(z, 1);
Serial.println();
counter++;
}
2023-01-27 07:07:04 -05:00
// -- END OF FILE --
2022-07-27 06:42:05 -04:00