ACCELEROMETER coding

Dependencies:   mbed ADXL345

Files at this revision

API Documentation at this revision

Comitter:
niveditasingh
Date:
Thu Jan 31 03:08:12 2019 +0000
Commit message:
accelerometer coding

Changed in this revision

ADXL345.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 1f7a1ee1012b ADXL345.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADXL345.lib	Thu Jan 31 03:08:12 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aberk/code/ADXL345/#bd8f0f20f433
diff -r 000000000000 -r 1f7a1ee1012b main.cpp
--- /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
diff -r 000000000000 -r 1f7a1ee1012b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 31 03:08:12 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file