acc sensor test

Dependencies:   mbed LIS3DH

Revision:
0:61c02ea0efd9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 04 03:13:18 2020 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "LIS3DH.h"
+DigitalOut myled(LED1);
+
+
+#if 0
+SPI STSPI(SPI_MOSI, SPI_MISO, SPI_SCK);
+DigitalOut STSPICS(D6); 
+#endif
+
+I2C Acc(PB_9, PB_8);  // SDA, SCL
+#define SLAVE_ADD 0x30  //LIS3DH I2C slave address
+LIS3DH acc(PB_9,PB_8, SLAVE_ADD );
+
+
+
+int main()
+{
+  int  val;  
+  float xyz[3];
+  printf("Hello LIS3DH test\r\n");
+  
+  val = acc.read_id();
+  printf("I2c read ID %02x\r\n",val);
+  while(1) {
+      myled = !myled;      
+      wait(0.5);
+      acc.data_ready();          
+      acc.read_data(xyz);
+      printf(" x=%f y=%f z=%f\r\n",xyz[0],xyz[1],xyz[2]);
+  }
+}
\ No newline at end of file