elderzhu 发表于 2015-12-23 00:37:59

LSM303 不显示 磁力计 数值


磁力计的 数值是 死在那里, 不动的。
帮忙看看是哪里出问题了。。。#include <Wire.h>
#include <LSM303DLH.h>
#define pi 3.14159

LSM303DLH compass;

void setup() {
Serial.begin(9600);
Wire.begin();
delay(100);
Serial.println("Starting up ...");
}

void loop() {
   
float G = sqrt(compass.a.x*compass.a.x+compass.a.y*compass.a.y+compass.a.z*compass.a.z);
//Serial.print(" G: ");
//Serial.print(G);
float angleA = asin(compass.a.x/G) * 180 / pi;
Serial.print(" INCL: ");
Serial.print((int)angleA);
float angleP = asin(compass.a.y/1000) * 180 / pi;
Serial.print(" P: ");
Serial.print((int)angleP);
compass.read();
Serial.print("A ");
Serial.print("X: ");
Serial.print((int)compass.a.x);
Serial.print(" Y: ");
Serial.print((int)compass.a.y);
Serial.print(" Z: ");
Serial.print((int)compass.a.z);
Serial.print(" M ");
Serial.print("X: ");
Serial.print((int)compass.m.x);
Serial.print(" Y: ");
Serial.print((int)compass.m.y);
Serial.print(" Z: ");
Serial.println((int)compass.m.z);
//float HeadingValue = (float) ((atan2f((float)compass.m.y,(float)compass.m.x))*180)/PI;
   //Serial.print(" Azim: ");
   // Serial.print((int)HeadingValue);
delay(100);
}

elderzhu 发表于 2015-12-23 16:31:35

没人回复。。。。。。。。。。。

elderzhu 发表于 2015-12-24 00:00:55

而且断电再启动所有数据就会都显示0了

维博哥哥 发表于 2016-3-4 16:26:59

这个模块有问题,我之前用的时候有这种问题,最后都没解决
页: [1]
查看完整版本: LSM303 不显示 磁力计 数值