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 TSI mbed
Fork of FRDM_TSI by
Diff: main.cpp
- Revision:
- 5:7f7b888f616b
- Parent:
- 1:51b1b688179a
--- a/main.cpp Tue Feb 19 23:53:04 2013 +0000
+++ b/main.cpp Mon Apr 22 09:25:48 2013 +0000
@@ -1,12 +1,30 @@
#include "mbed.h"
#include "TSISensor.h"
+#include "MMA8451Q.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
int main(void) {
- PwmOut led(LED_GREEN);
- TSISensor tsi;
+ MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+
+ PwmOut led1(LED_BLUE);
+ PwmOut led2(LED_GREEN);
+ PwmOut led3(LED_RED);
+
+ float tp=0;
- while (true) {
- led = 1.0 - tsi.readPercentage();
- wait(0.1);
+ TSISensor tsi;
+
+ led1 = 1;
+ led2 = 1;
+ led3 = 1;
+
+ while (1)
+ {
+ tp = (tsi.readPercentage()>0)?tsi.readPercentage():tp;
+ led1 = (tsi.readPercentage()==0)?(1-abs(acc.getAccX())):((tp>0.00 && tp <= 0.33)?(1-(tp-0.00)*3):1);
+ led2 = (tsi.readPercentage()==0)?(1-abs(acc.getAccY())):((tp>=0.34 && tp <= 0.66)?(1-(tp-0.33)*3):1);
+ led3 = (tsi.readPercentage()==0)?(1-abs(acc.getAccZ())):((tp>=0.67 && tp <= 0.99)?(1-(tp-0.66)*3):1);
+ wait(0.1);
}
}
\ No newline at end of file
