EXP8

Dependencies:   MMA8451Q TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
rx5
Date:
Wed Apr 13 05:39:58 2016 +0000
Commit message:
EXP8

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.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 8273605d433b MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Wed Apr 13 05:39:58 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r 000000000000 -r 8273605d433b TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed Apr 13 05:39:58 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 8273605d433b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 13 05:39:58 2016 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#include "TextLCD.h"
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+TextLCD lcd(D2, D3, D4, D5, D6, D7); // LCD PIN => RS, EN, Data4, Data5, Data6, Data7
+
+PinName const SDA = PTE25; //I2C Pins for KL25Z
+PinName const SCL = PTE24; //I2C Pins for KL25Z
+
+MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); //Initilize MMA8451Q Accelerometer 
+
+int main(void)
+{
+    lcd.cls(); // Clear LCD
+    lcd.locate(0,0); // cursor on Col=0, Raw=0
+    lcd.printf("Experiment - 8"); // print startup message on LCD first Raw
+    lcd.locate(0,1); // cursor on Col=0, Raw=1
+    lcd.printf("MMA8451 With LCD"); // print startup message on LCD second Raw
+    wait(3.0); // wait 3 second to show startup message
+    while (1) 
+    {
+        float x, y, z;
+        x = acc.getAccX(); // get Acceleration on X
+        y = acc.getAccY(); // get Acceleration on Y
+        z = acc.getAccZ(); // get Acceleration on Z
+        lcd.cls(); // Clear LCD
+        lcd.locate(0,0); // cursor on Col=0, Raw=0
+        lcd.printf("X:%0.2f",x); // print value of X in first line of LCD
+        lcd.locate(8,0); // cursor on Col=8, Raw=0
+        lcd.printf("Y:%0.2f",y); // print value of Y in first line of LCD
+        lcd.locate(4,1); // cursor on Col=5, Raw=1
+        lcd.printf("Z:%0.2f",z); // print value of Z in first line of LCD
+        wait(0.1); // Wait for 100ms to visulize reading on LCD
+        
+    }
+}
diff -r 000000000000 -r 8273605d433b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 13 05:39:58 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/99a22ba036c9
\ No newline at end of file