Device to measure angle and get IMU measurements.

Dependencies:   mbed commands BLE_API nRF51822

main.cpp

Committer:
dkester
Date:
2015-05-20
Revision:
0:1c5088dae6e1
Child:
1:b44bd62c542f

File content as of revision 0:1c5088dae6e1:

#include "mbed.h"
#include "Sensors.h"

Serial pc(USBTX, USBRX);

DigitalOut  led(p21);
InterruptIn   button(p23);
Ticker ticker;

void printSensors(void)
{
    Sensors* sensors = Sensors::getInstance();
    sensors->updateIMU();
    pc.printf("angle: %.2f\n", sensors->getAngle());
    pc.printf("accelerometer x: %d y: %d z: %d\n",sensors->getAccelX(),sensors->getAccelY(),sensors->getAccelZ());
    pc.printf("temperature: %.2f\n", sensors->getTemp());
    pc.printf("gyroscope x: %d y: %d z: %d\n\n",sensors->getGyroX(),sensors->getGyroY(),sensors->getGyroZ());
}

void buttonInt( void )
{
    led = !led;
}

int main(void)
{
    pc.baud(19200);
    led = 0;
    
    
    ticker.attach(&printSensors,0.1);
    button.fall(&buttonInt);

    while(true) {
        /*
        if(led == 1) {
            printSensors();
        }
        */
        wait(0.01);
    }
}