accelorometer and touch pad

Dependencies:   MMA8451Q TSIServo mbed

Fork of FRDM_MMA8451Q by mbed official

Committer:
cindyC12
Date:
Sun Sep 23 04:41:13 2018 +0000
Revision:
8:0d24df2d4f18
Parent:
5:bf5becf7469c
Child:
9:1f50587ada14
it work. sortof

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 2:41db78380a6e 1 #include "mbed.h"
chris 2:41db78380a6e 2 #include "MMA8451Q.h"
cindyC12 8:0d24df2d4f18 3 #include "TSISensor.h"
chris 2:41db78380a6e 4
chris 2:41db78380a6e 5 #define MMA8451_I2C_ADDRESS (0x1d<<1)
chris 2:41db78380a6e 6
chris 4:367de1084ea9 7 int main(void) {
emilmont 5:bf5becf7469c 8 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
cindyC12 8:0d24df2d4f18 9 PwmOut r(LED_RED);
cindyC12 8:0d24df2d4f18 10 PwmOut g(LED_GREEN);
cindyC12 8:0d24df2d4f18 11 PwmOut b(LED_BLUE);
cindyC12 8:0d24df2d4f18 12 TSISensor tsi;
cindyC12 8:0d24df2d4f18 13 float readPercentage();
cindyC12 8:0d24df2d4f18 14
chris 4:367de1084ea9 15
emilmont 5:bf5becf7469c 16 while (true) {
cindyC12 8:0d24df2d4f18 17 r = abs(acc.getAccX()* tsi.readPercentage());
cindyC12 8:0d24df2d4f18 18 r = 1.0 - (r*tsi.readPercentage());
cindyC12 8:0d24df2d4f18 19 g = abs(acc.getAccY()* tsi.readPercentage());
cindyC12 8:0d24df2d4f18 20 g = 1.0 - (g*tsi.readPercentage());
cindyC12 8:0d24df2d4f18 21 b = abs(acc.getAccZ()* tsi.readPercentage());
cindyC12 8:0d24df2d4f18 22 b = 1.0 - (b*tsi.readPercentage());
chris 3:f2d3e041d8f2 23 wait(0.1);
chris 2:41db78380a6e 24 }
chris 2:41db78380a6e 25 }