Simple program that outputs the MMA7660-Accelerometer values.

Dependencies:   MMA7660 mbed

Files at this revision

API Documentation at this revision

Comitter:
dvn
Date:
Thu Jun 21 22:50:35 2018 +0000
Commit message:
Program that outputs the reading MMA7660-Accelerometer every second.

Changed in this revision

MMA7660.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 9ab8796304e5 MMA7660.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Thu Jun 21 22:50:35 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/MMA7660/#36a163511e34
diff -r 000000000000 -r 9ab8796304e5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 21 22:50:35 2018 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+
+// Reference the MMA7660-Accelerometer library.
+#include "MMA7660.h"
+
+/*
+    Variables definition:
+        - LOOP_FOREVER  the infinity value.
+        - ONE_SECOND_MILLISECOND one second in milliseconds
+*/
+#define LOOP_FOREVER 1
+#define ONE_SECOND_MILLISECOND 1000
+
+// Accelerometer object reference.
+MMA7660 MMA(p28, p27);
+
+// Led reference is show when Accelerometer is connected.
+DigitalOut connectionLed(LED1);
+
+/** 
+*
+* @file mbed_lab_2_Q_1.cpp
+* @brief Using the MMA7660-Accelerometer library. 
+* @details Write a program using the ‘MMA’ interface on the mbed application
+* @details board to interface the on board accelerometer. 
+* @details Print the X Y and Z every second.
+* @author cdonovan
+* @version 0.0.1
+*
+*/
+int main()
+{
+    // Checks the MMA Connection 
+    if (MMA.testConnection()) {
+        // Enabled the Led
+        connectionLed=1;
+        
+        // Start the Loop
+        while(LOOP_FOREVER) {
+            // Print out the Accelerometer readings
+            printf("x:%lf y:%lf z:%lf\r\n",MMA.x(),MMA.y(),MMA.z());
+            // Wait for a second
+            wait_ms(ONE_SECOND_MILLISECOND);
+        } // _END_OF_LOOP_
+    }
+} // _END_OF_MAIN_FUNCTION_
\ No newline at end of file
diff -r 000000000000 -r 9ab8796304e5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 21 22:50:35 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file