ACCELEROMETER coding

Dependencies:   mbed ADXL345

Revision:
0:1f7a1ee1012b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 31 03:08:12 2019 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "ADXL345.h"
+ADXL345 accelerometer (PC_12, PC_11, PC_10, PB_6);
+DigitalOut greenLed(LED1);
+Serial pc(USBTX, USBRX);
+int main()
+{
+    pc.baud(115200);
+    int readings[3] = {0,0,0};
+    pc.printf("Accelerometer Started Now\n");
+    pc.printf("starting ADXL345test \n");
+    pc.printf("Device ID is : 0x%02x\n",accelerometer.getDevId());
+    accelerometer.setPowerControl(0x00);
+    accelerometer.setDataFormatControl(0x0B);
+    accelerometer.setDataRate(ADXL345_3200HZ);
+    accelerometer.setPowerControl(0x08);
+    while(1)
+    {
+        greenLed=!greenLed;
+        wait(0.5);
+        accelerometer.getOutput(readings);
+        pc.printf("%d,%d,%d\n",(int16_t)readings[0],(int16_t)readings[1],(int16_t) readings[2]);
+       
+   
+        }
+        }
\ No newline at end of file