accelorometer and touch pad

Dependencies:   MMA8451Q TSIServo mbed

Fork of FRDM_MMA8451Q by mbed official

main.cpp

Committer:
cindyC12
Date:
2018-09-27
Revision:
9:1f50587ada14
Parent:
8:0d24df2d4f18
Child:
10:ac7dd2ffbd14

File content as of revision 9:1f50587ada14:

#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;
 

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