Zu Frage 1:
Mit den rot/grünen Befehlen wird der Sensor eingestellt ( 1.Wert: Registeraddresse, 2.Wert: Registerwert).
Was da gemacht wird kannst du im Chip-Datenblatt erfahren:
Control Register 09H, Wert 1DH:
Mode: Continuous
Output Data Rate: 200Hz
Full Scale: 8Gauss
Over Sample Ratio: 512
Set/Reset Period Register 0BH:
Setzen der Periode -> 1 startet Messungen
Zu Frage 2:
Wenn du
inCode:if (6 <= Wire.available()) { x = Wire.read(); // MSB x x |= Wire.read() << 8; // LSB x z = Wire.read(); // MSB z z |= Wire.read() << 8; // LSB z y = Wire.read(); // MSB y y |= Wire.read() << 8; // LSB y } int angle = atan2(-y , x) / M_PI * 180; // angle is atan(-y/x)änderst, sollte das auf dem Board aufgedruckte Koordinatensystem verwendet werden.Code:if (6 <= Wire.available()) { x = Wire.read(); // MSB x x |= Wire.read() << 8; // LSB x y = Wire.read(); // MSB y y |= Wire.read() << 8; // LSB y z = Wire.read(); // MSB z z |= Wire.read() << 8; // LSB z } int angle = atan2(y , x) / M_PI * 180; // angle is atan(y/x)






Zitieren


Lesezeichen