Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q TextLCD mbed
Fork of FRDM_MMA8451Q by
Revision 8:a2b340994747, committed 2013-12-10
- Comitter:
- amarincan
- Date:
- Tue Dec 10 19:26:21 2013 +0000
- Parent:
- 7:70775be9f474
- Commit message:
- acelerometro interno de la tarjeta integrado a un LCD
Changed in this revision
| 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Dec 10 19:26:21 2013 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- a/main.cpp Tue Feb 19 23:46:45 2013 +0000
+++ b/main.cpp Tue Dec 10 19:26:21 2013 +0000
@@ -1,18 +1,43 @@
#include "mbed.h"
#include "MMA8451Q.h"
+#include "TextLCD.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
+float acx=0,acy=0,acz=0;
+
int main(void) {
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
PwmOut rled(LED_RED);
PwmOut gled(LED_GREEN);
PwmOut bled(LED_BLUE);
-
+ lcd.printf("Acelerometro");
+ wait(2);
+ lcd.locate(0,0);
+ lcd.printf("acx=0 acy=0");
+ lcd.locate(0,1);
+ lcd.printf("acz=0 ");
while (true) {
rled = 1.0 - abs(acc.getAccX());
+ acx=1.0 - abs(acc.getAccX());
gled = 1.0 - abs(acc.getAccY());
+ acy=1.0 - abs(acc.getAccY());
bled = 1.0 - abs(acc.getAccZ());
- wait(0.1);
+ acz=1.0 - abs(acc.getAccZ());
+
+ lcd.locate(4,0);
+ lcd.printf(" ");
+ lcd.locate(4,0);
+ lcd.printf("%1.2f",acx);
+ lcd.locate(12,0);
+ lcd.printf(" ");
+ lcd.locate(12,0);
+ lcd.printf("%1.2f",acy);
+ lcd.locate(4,1);
+ lcd.printf(" ");
+ lcd.locate(4,1);
+ lcd.printf("%1.2f",acz);
+ wait(0.2);
}
}
