adsfawre

Dependencies:   MMA7660 mbed

Fork of MMA7660_HelloWorld by Erik -

main.cpp

Committer:
ogris
Date:
2017-04-05
Revision:
3:f23f1ba7aeaa
Parent:
0:bd0546063b0a

File content as of revision 3:f23f1ba7aeaa:

//Uses the measured z-acceleration to drive leds 2 and 3 of the mbed

#include "mbed.h"
#include "MMA7660.h"

MMA7660 MMA(p28, p27);
Serial pc(USBTX,USBRX);


DigitalOut connectionLed(LED1);

int main() {  
float x=0,y=0,z=0;
    pc.baud(115200);
    if (MMA.testConnection()){
                connectionLed = 1;
               pc.printf("connected \n");
        }
        
        
    while(1) {
        x += MMA.x();
        y += MMA.y();
        z += MMA.z();
        x = x/2;
        y = y/2;
        z = z/2;
        pc.printf(":%lf;%lf;%lf\n",x,y,z);
        wait_ms(100);
    }

}