ajout de l'imu pour nucleo
Dependencies: mbed HC_SR04_Ultrasonic_Library IMU_FIP_nucleo Nucleo_Sensor_Shield VL6180x_lib
main.cpp
- Committer:
- quentin9696
- Date:
- 2015-04-10
- Revision:
- 7:dc76d89a8d51
- Parent:
- 2:32226f1d12e5
- Child:
- 8:e3d7a4a34088
File content as of revision 7:dc76d89a8d51:
#include "mbed.h" #include "ultrasonic.h" #include "Imu.h" /* void dist(int distance) { //put code here to happen when the distance is changed printf("Distance changed to %dmm\r\n", distance); } ultrasonic mu(D8, D9, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9 //have updates every .1 seconds and a timeout after 1 //second, and call dist when the distance changes int main() { mu.startUpdates();//start mesuring the distance while(1) { //Do something else here mu.checkDistance(); //call checkDistance() as much as possible, as this is where //the class checks if dist needs to be called. } }*/ Imu i; Serial pc(SERIAL_TX, SERIAL_RX); DigitalOut myled(LED1); Data_IMU * foo; Data_IMU * bar; int main() { i.setOffset(); foo = i.getOffset(); bar = i.getData(); while(1) { myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(10); i.refresh(1); pc.printf("OFFSET : \r\n"); pc.printf("Temperature:\t\t %f C\r\n", foo->TEMPERATURE_Value_C); pc.printf("Humidity:\t\t %f%%\r\n", foo->HUMIDITY_Value); pc.printf("Pressure:\t\t %f hPa\r\n", foo->PRESSURE_Value); pc.printf("Magnetometer (mGauss):\t X: %d, Y: %d, Z: %d\r\n", foo->MAG_Value->AXIS_X, foo->MAG_Value->AXIS_Y, foo->MAG_Value->AXIS_Z); pc.printf("Accelerometer (mg):\t X: %d, Y: %d, Z: %d\r\n", foo->ACC_Value->AXIS_X, foo->ACC_Value->AXIS_Y, foo->ACC_Value->AXIS_Z); pc.printf("Gyroscope (mdps):\t X: %d, Y: %d, Z: %d\r\n", foo->GYR_Value->AXIS_X, foo->GYR_Value->AXIS_Y, foo->GYR_Value->AXIS_Z); pc.printf("\r\n"); pc.printf("OFFSET DATA : \r\n"); pc.printf("Temperature:\t\t %f C\r\n", bar->TEMPERATURE_Value_C); pc.printf("Humidity:\t\t %f%%\r\n", bar->HUMIDITY_Value); pc.printf("Pressure:\t\t %f hPa\r\n", bar->PRESSURE_Value); pc.printf("Magnetometer (mGauss):\t X: %d, Y: %d, Z: %d\r\n", bar->MAG_Value->AXIS_X, bar->MAG_Value->AXIS_Y, bar->MAG_Value->AXIS_Z); pc.printf("Accelerometer (mg):\t X: %d, Y: %d, Z: %d\r\n", bar->ACC_Value->AXIS_X, bar->ACC_Value->AXIS_Y, bar->ACC_Value->AXIS_Z); pc.printf("Gyroscope (mdps):\t X: %d, Y: %d, Z: %d\r\n", bar->GYR_Value->AXIS_X, bar->GYR_Value->AXIS_Y, bar->GYR_Value->AXIS_Z); pc.printf("\r\n"); } }