-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d45a16
commit 3120105
Showing
7 changed files
with
199 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
examples/GY521_performance_calibrate/GY521_performance_calibrate.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// FILE: GY521_performance_calibrate.ino | ||
// AUTHOR: Rob Tillaart | ||
// PURPOSE: read angleX, angleY, angleZ | ||
// URL: https://github.com/RobTillaart/GY521 | ||
|
||
|
||
#include "GY521.h" | ||
|
||
GY521 sensor(0x68); | ||
|
||
|
||
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: please check the GY521 address (0x68/0x69)"); | ||
delay(1000); | ||
} | ||
sensor.setAccelSensitivity(0); // 2g | ||
sensor.setGyroSensitivity(0); // 250 degrees/s | ||
sensor.setThrottle(false); | ||
|
||
test(100); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
Serial.println("\n\tTIME\tACCELEROMETER\t\tGYROSCOPE"); | ||
for (uint16_t times = 20; times <= 500; times += 20) | ||
{ | ||
test(times); | ||
} | ||
} | ||
|
||
|
||
|
||
void test(uint16_t times) | ||
{ | ||
// flush all output | ||
delay(100); | ||
uint32_t start = micros(); | ||
sensor.calibrate(100); | ||
uint32_t duration = micros() - start; | ||
|
||
// print results | ||
Serial.print(times); | ||
Serial.print('\t'); | ||
Serial.print(duration); | ||
Serial.print('\t'); | ||
Serial.print(sensor.axe, 3); | ||
Serial.print('\t'); | ||
Serial.print(sensor.aye, 3); | ||
Serial.print('\t'); | ||
Serial.print(sensor.aze, 3); | ||
Serial.print('\t'); | ||
Serial.print(sensor.gxe, 3); | ||
Serial.print('\t'); | ||
Serial.print(sensor.gye, 3); | ||
Serial.print('\t'); | ||
Serial.print(sensor.gze, 3); | ||
Serial.print('\n'); | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.