1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <Wire.h>
#include <LIS3DSH.h>
float K = 0.061; // (4000/65535) milli-g per digit for +/-2g full scale using 16 bit digital output
LIS3DSH accel;
#define offset_x= 0x10 ;
#define offset_y=0x11;
#define offset_z=0x12;
float Acc_X, Acc_Y, Acc_Z ;
void setup()
{
Serial.begin(9600);
Wire.begin();
accel.enableDefault();
}
void loop()
{
int16_t x, y, z;
//int8_t temperature;
accel.readAccel(&x, &y, &z);
accel.readTemperature(&temperature);
Acc_X= ((x)-offset_x*32);
Acc_Y= ((y)-offset_y*32);
Acc_Z= ((z)-offset_Z*32);
Serial.print("Accel ");
Serial.print("X: ");
Serial.print(x);
Serial.print(" Y: ");
Serial.print(y);
Serial.print(" Z: ");
Serial.print(z);
Serial.print(" T: ");
//Serial.println(temperature);
delay(1000);
} |
Partager