Output the result from the accelerometer to the LCD
Dependencies: MMA8451Q TextLCD TextLCD_HelloWorld mbed
Fork of TextLCD_HelloWorld by
main.cpp
- Committer:
- zenglingxuan
- Date:
- 2013-05-01
- Revision:
- 3:6bb3b92a4f08
- Parent:
- 2:ad0b044d0a10
File content as of revision 3:6bb3b92a4f08:
// Hello World! for the TextLCD #include "mbed.h" #include "TextLCD.h" #include "MMA8451Q.h" Serial pc(USBTX,USBRX); DigitalOut led1(PTB8); DigitalOut grnd(PTB9); TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 int main() { 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); } }