acc sensor test

Dependencies:   mbed LIS3DH

Files at this revision

API Documentation at this revision

Comitter:
hakusan270
Date:
Wed Nov 04 03:13:18 2020 +0000
Commit message:
LIS3DH sample

Changed in this revision

LIS3DH.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 61c02ea0efd9 LIS3DH.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LIS3DH.lib	Wed Nov 04 03:13:18 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kenjiArai/code/LIS3DH/#0999d25ed7bc
diff -r 000000000000 -r 61c02ea0efd9 main.cpp
--- /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
diff -r 000000000000 -r 61c02ea0efd9 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 04 03:13:18 2020 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20
\ No newline at end of file