diff options
author | HampusM <hampus@hampusmat.com> | 2021-12-20 20:36:51 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-12-20 20:36:51 +0100 |
commit | 135ecb444644079983de7123a0fdf0c21fa68a14 (patch) | |
tree | 7a86afee6c010b38190990a5923f0c4d58cb4bac /src/gyro.cpp | |
parent | 2bcbead3d8e189493efc5066c61755f4ad138223 (diff) |
style: fix line endings
Diffstat (limited to 'src/gyro.cpp')
-rw-r--r-- | src/gyro.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/src/gyro.cpp b/src/gyro.cpp index 78498bc..668cef1 100644 --- a/src/gyro.cpp +++ b/src/gyro.cpp @@ -1,46 +1,46 @@ -#include "Arduino.h"
-#include "GY521.h"
-
-GY521 sensor(0x68);
-
-void setup()
-{
- Serial.begin(9600);
-
- // Wait for Serial because the Arduino Leonardo is weird
- while (!Serial) {}
-
- Wire.begin();
-
- delay(100);
- while (!sensor.wakeup())
- {
- Serial.print(millis());
- Serial.println("Error: Could not connect to the GY521 sensor. Retrying after 2000 milliseconds...");
- delay(2000);
- }
- sensor.setAccelSensitivity(2); // 8g
- sensor.setGyroSensitivity(1); // 500 degrees/s
-
- sensor.setThrottle();
- Serial.println("start...");
-
- // Calibration values
- sensor.axe = 0.198;
- sensor.aye = -0.018;
- sensor.gxe = 0.780;
- sensor.gye = -1.495;
-}
-
-void loop()
-{
- sensor.read();
- float pitch = sensor.getPitch();
- float roll = sensor.getRoll();
-
- Serial.print("Pitch: ");
- Serial.print(pitch, 3);
- Serial.print(" Roll: ");
- Serial.print(roll, 3);
- Serial.println();
-}
\ No newline at end of file +#include "Arduino.h" +#include "GY521.h" + +GY521 sensor(0x68); + +void setup() +{ + Serial.begin(9600); + + // Wait for Serial because the Arduino Leonardo is weird + while (!Serial) {} + + Wire.begin(); + + delay(100); + while (!sensor.wakeup()) + { + Serial.print(millis()); + Serial.println("Error: Could not connect to the GY521 sensor. Retrying after 2000 milliseconds..."); + delay(2000); + } + sensor.setAccelSensitivity(2); // 8g + sensor.setGyroSensitivity(1); // 500 degrees/s + + sensor.setThrottle(); + Serial.println("start..."); + + // Calibration values + sensor.axe = 0.198; + sensor.aye = -0.018; + sensor.gxe = 0.780; + sensor.gye = -1.495; +} + +void loop() +{ + sensor.read(); + float pitch = sensor.getPitch(); + float roll = sensor.getRoll(); + + Serial.print("Pitch: "); + Serial.print(pitch, 3); + Serial.print(" Roll: "); + Serial.print(roll, 3); + Serial.println(); +} |