Output the result from the accelerometer to the LCD
Dependencies: MMA8451Q TextLCD TextLCD_HelloWorld mbed
Fork of TextLCD_HelloWorld by
Diff: main.cpp
- Revision:
- 3:6bb3b92a4f08
- Parent:
- 2:ad0b044d0a10
--- 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); + } }