Output the result from the accelerometer to the LCD

Dependencies:   MMA8451Q TextLCD TextLCD_HelloWorld mbed

Fork of TextLCD_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
zenglingxuan
Date:
Wed May 01 11:15:47 2013 +0000
Parent:
2:ad0b044d0a10
Commit message:
LCD helloworld

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD_HelloWorld.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 ad0b044d0a10 -r 6bb3b92a4f08 MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Wed May 01 11:15:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r ad0b044d0a10 -r 6bb3b92a4f08 TextLCD_HelloWorld.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD_HelloWorld.lib	Wed May 01 11:15:47 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/simon/code/TextLCD_HelloWorld/#ad0b044d0a10
diff -r ad0b044d0a10 -r 6bb3b92a4f08 main.cpp
--- a/main.cpp	Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp	Wed May 01 11:15:47 2013 +0000
@@ -2,9 +2,44 @@
 
 #include "mbed.h"
 #include "TextLCD.h"
+#include "MMA8451Q.h"
+Serial pc(USBTX,USBRX);
+DigitalOut led1(PTB8);
+DigitalOut grnd(PTB9);
 
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
 
 int main() {
-    lcd.printf("Hello World!\n");
+    grnd=0;
+    lcd.printf("1 on, 0 off\n");
+    char c;
+    char f;
+    f=1;
+    char x;
+    char y;
+    char z;
+    
+    while(1){
+    c=pc.getc();
+    
+     x = abs(acc.getAccX());
+     y = abs(acc.getAccY());
+     z = abs(acc.getAccZ());
+    
+    lcd.printf("%c",c);
+    lcd.printf("%c",x);
+    lcd.printf("%c",y);
+    lcd.printf("%c",z);
+    if (c=='1'){
+    f=0xFF;
+    }
+    if(c=='0'){
+    f=0x00;
+    }
+    else{
+    f=f;
+    }
+    led1=f;
+    wait(0.1);
+    }
 }
diff -r ad0b044d0a10 -r 6bb3b92a4f08 mbed.bld
--- a/mbed.bld	Sat Dec 04 11:31:07 2010 +0000
+++ b/mbed.bld	Wed May 01 11:15:47 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
+http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd
\ No newline at end of file