accelorometer and touch pad

Dependencies:   MMA8451Q TSIServo mbed

Fork of FRDM_MMA8451Q by mbed official

main.cpp

Committer:
cindyC12
Date:
2018-09-23
Revision:
8:0d24df2d4f18
Parent:
5:bf5becf7469c
Child:
9:1f50587ada14

File content as of revision 8:0d24df2d4f18:

#include "mbed.h"
#include "MMA8451Q.h"
#include "TSISensor.h"

#define MMA8451_I2C_ADDRESS (0x1d<<1)

int main(void) {
    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
    PwmOut r(LED_RED);
    PwmOut g(LED_GREEN);
    PwmOut b(LED_BLUE);
     TSISensor tsi;
     float readPercentage();
     

    while (true) {
        r = abs(acc.getAccX()* tsi.readPercentage());
        r = 1.0 - (r*tsi.readPercentage());
        g = abs(acc.getAccY()* tsi.readPercentage());
        g = 1.0 - (g*tsi.readPercentage());
        b = abs(acc.getAccZ()* tsi.readPercentage());
        b = 1.0 - (b*tsi.readPercentage());
        wait(0.1);
    }
}