AUP_Lab5_MMA7660
Dependencies: C12832 MMA7660 mbed
Fork of AUP_Lab4_LCD by
Revision 2:09ee85ab1717, committed 2015-07-08
- Comitter:
- BrentLei
- Date:
- Wed Jul 08 00:05:05 2015 +0000
- Parent:
- 1:08431d9e3d95
- Commit message:
- test
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA7660.lib Wed Jul 08 00:05:05 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- a/main.cpp Tue Jul 07 23:27:48 2015 +0000 +++ b/main.cpp Wed Jul 08 00:05:05 2015 +0000 @@ -1,12 +1,18 @@ #include "mbed.h" #include "C12832.h" +// 添加MMA7660库文件 +#include "MMA7660.h" + PwmOut led(D5); DigitalIn button_up(A2); DigitalIn button_center(D4); DigitalIn button_down(A3); C12832 lcd(D11, D13, D12, D7, D10); +// 初始化MMA7660 +MMA7660 MMA(D14, D15); + double brightness = 1.0; double brightness_inc = 0.1; @@ -14,9 +20,6 @@ { int bt_flag = 0; lcd.cls(); - lcd.locate(0,0); - lcd.printf("Hello PWM!\r\n"); - // Set PWM led.write(brightness); while (1) { @@ -34,9 +37,12 @@ brightness = (brightness>1.0)?0.0:brightness; brightness = (brightness<0.0)?1.0:brightness; led.write(brightness); - lcd.locate(0,0); - lcd.printf("Brightness = %.1f\r\n", 1.0-brightness); } - wait(0.2); // 200 ms + lcd.locate(0, 0); + lcd.printf("Brightness = %.1f\r\n", 1.0 - brightness); + + // 显示加速度计的测量结果 + lcd.printf("x=%.2f y=%.2f z=%.2f", MMA.x(), MMA.y(), MMA.z()); + wait(0.2); } }