Created
November 11, 2017 01:36
-
-
Save esmarr58/1f1a7e9c980d444a1e36d5e26510b788 to your computer and use it in GitHub Desktop.
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
void loop(){ | |
int error; | |
double dT; | |
accel_t_gyro_union accel_t_gyro; | |
error = MPU6050_read (MPU6050_ACCEL_XOUT_H,(uint8_t *)&accel_t_gyro,sizeof(accel_t_gyro)); | |
uint8_t swap; | |
#define SWAP(x,y) swap = x; x = y; y = swap | |
SWAP (accel_t_gyro.reg.x_accel_h, accel_t_gyro.reg.x_accel_l); | |
SWAP (accel_t_gyro.reg.y_accel_h, accel_t_gyro.reg.y_accel_l); | |
SWAP (accel_t_gyro.reg.z_accel_h, accel_t_gyro.reg.z_accel_l); | |
SWAP (accel_t_gyro.reg.t_h, accel_t_gyro.reg.t_l); | |
SWAP (accel_t_gyro.reg.x_gyro_h, accel_t_gyro.reg.x_gyro_l); | |
SWAP (accel_t_gyro.reg.y_gyro_h, accel_t_gyro.reg.y_gyro_l); | |
SWAP (accel_t_gyro.reg.z_gyro_h, accel_t_gyro.reg.z_gyro_l); | |
int accel_x, accel_y, accel_z; | |
accel_x=accel_t_gyro.value.x_accel*0.061035156; | |
accel_y=accel_t_gyro.value.y_accel*0.061035156; | |
accel_z=accel_t_gyro.value.z_accel*0.061035156; | |
Serial.print(F("Aceleracion: x=")); | |
Serial.print(accel_x, DEC); | |
Serial.print(F(" mG, y=")); | |
Serial.print(accel_y, DEC); | |
Serial.print(F(" mG, z=")); | |
Serial.print(accel_z, DEC); | |
Serial.print(F(" mG, Giroscopio: x=")); | |
Serial.print(accel_t_gyro.value.x_gyro, DEC); | |
Serial.print(F(" b, y=")); | |
Serial.print(accel_t_gyro.value.y_gyro, DEC); | |
Serial.print(F(" b, z=")); | |
Serial.print(accel_t_gyro.value.z_gyro, DEC); | |
Serial.print(F(", Temp: ")); | |
dT = ( (double) accel_t_gyro.value.temperature + 12412.0) / 340.0; | |
Serial.print(dT, 3); | |
Serial.println(F(" C")); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment