Program using Touch plane and accelerometer of FRDM-KL25Z board
Dependencies: MMA8451Q TSI mbed
Fork of FRDM_TSI by
main.cpp@5:7f7b888f616b, 2013-04-22 (annotated)
- Committer:
- subhrajitmitra
- Date:
- Mon Apr 22 09:25:48 2013 +0000
- Revision:
- 5:7f7b888f616b
- Parent:
- 1:51b1b688179a
using of touch pad and accelerometer of FRDM-KL25Z
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 0:0f00f07ebde0 | 1 | #include "mbed.h" |
chris | 1:51b1b688179a | 2 | #include "TSISensor.h" |
subhrajitmitra | 5:7f7b888f616b | 3 | #include "MMA8451Q.h" |
subhrajitmitra | 5:7f7b888f616b | 4 | |
subhrajitmitra | 5:7f7b888f616b | 5 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
emilmont | 0:0f00f07ebde0 | 6 | |
emilmont | 0:0f00f07ebde0 | 7 | int main(void) { |
subhrajitmitra | 5:7f7b888f616b | 8 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
subhrajitmitra | 5:7f7b888f616b | 9 | |
subhrajitmitra | 5:7f7b888f616b | 10 | PwmOut led1(LED_BLUE); |
subhrajitmitra | 5:7f7b888f616b | 11 | PwmOut led2(LED_GREEN); |
subhrajitmitra | 5:7f7b888f616b | 12 | PwmOut led3(LED_RED); |
subhrajitmitra | 5:7f7b888f616b | 13 | |
subhrajitmitra | 5:7f7b888f616b | 14 | float tp=0; |
emilmont | 0:0f00f07ebde0 | 15 | |
subhrajitmitra | 5:7f7b888f616b | 16 | TSISensor tsi; |
subhrajitmitra | 5:7f7b888f616b | 17 | |
subhrajitmitra | 5:7f7b888f616b | 18 | led1 = 1; |
subhrajitmitra | 5:7f7b888f616b | 19 | led2 = 1; |
subhrajitmitra | 5:7f7b888f616b | 20 | led3 = 1; |
subhrajitmitra | 5:7f7b888f616b | 21 | |
subhrajitmitra | 5:7f7b888f616b | 22 | while (1) |
subhrajitmitra | 5:7f7b888f616b | 23 | { |
subhrajitmitra | 5:7f7b888f616b | 24 | tp = (tsi.readPercentage()>0)?tsi.readPercentage():tp; |
subhrajitmitra | 5:7f7b888f616b | 25 | led1 = (tsi.readPercentage()==0)?(1-abs(acc.getAccX())):((tp>0.00 && tp <= 0.33)?(1-(tp-0.00)*3):1); |
subhrajitmitra | 5:7f7b888f616b | 26 | led2 = (tsi.readPercentage()==0)?(1-abs(acc.getAccY())):((tp>=0.34 && tp <= 0.66)?(1-(tp-0.33)*3):1); |
subhrajitmitra | 5:7f7b888f616b | 27 | led3 = (tsi.readPercentage()==0)?(1-abs(acc.getAccZ())):((tp>=0.67 && tp <= 0.99)?(1-(tp-0.66)*3):1); |
subhrajitmitra | 5:7f7b888f616b | 28 | wait(0.1); |
emilmont | 0:0f00f07ebde0 | 29 | } |
chris | 1:51b1b688179a | 30 | } |