
Sorry if I've missed something really obvious, any help would be appreciated. THE MENTIONED CODE:
Code: Select all
#include <Wire.h>
float RateRoll, RatePitch, RateYaw;
void gyro_signals(void) {
Wire.beginTransmission(0x68);
Wire.write(0x1A);//accessing configuration (register 26)
Wire.write(0x05);//setting DLPF value to 5 (101)
Wire.endTransmission();
Wire.beginTransmission(0x68);
Wire.write(0x1B);//accessing gyroscope configuration (register 27)
Wire.write(0x8);//setting 'FS_SEL' value to 1
Wire.endTransmission();
Wire.beginTransmission(0x68);
Wire.write(0x43);//setting the first of gyroscopic mesurments register (register 67)
Wire.endTransmission();
Wire.requestFrom(0x68,6);//requesting 6 bytes from the one selected before
int16_t GyroX=Wire.read();//setting the values up
Wire.read();
int16_t GyroY=Wire.read();
Wire.read();
int16_t GyroZ=Wire.read();
Wire.read();
RateRoll=(float)GyroX/65.5;//caluclating designated values
RatePitch=(float)GyroY/65.5;
RateYaw=(float)GyroZ/65.5;
}
void setup() {
Serial.begin(57600);//initialization of serial communication
Wire.setClock(400000);//mathing 400kHz frequency of mpu6050
Wire.begin(PB6,PB7);
delay(250);//waiting for mpu6050 to turn on.
Wire.beginTransmission(0x68);
Wire.write(0x6B);//setting the power management 1 settings
Wire.write(0x00);// -||-
Wire.endTransmission();
}
void loop() {
gyro_signals();//function callout
Serial.print("Roll rate [°/s]= ");//printing the values
Serial.print(RateRoll);
Serial.print(" Pitch Rate [°/s]= ");
Serial.print(RatePitch);
Serial.print(" Yaw Rate [°/s]= ");
Serial.println(RateYaw);
delay(50);//for readability
}