![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ciao
Dependencies: X_NUCLEO_IKS01A2 mbed
Fork of HelloWorld_IKS01A2 by
Revision 18:28f274efbdba, committed 2017-10-13
- Comitter:
- franc_unina
- Date:
- Fri Oct 13 14:29:47 2017 +0000
- Parent:
- 17:175f561f1a71
- Commit message:
- cciao
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 27 15:48:21 2017 +0000 +++ b/main.cpp Fri Oct 13 14:29:47 2017 +0000 @@ -50,6 +50,8 @@ static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro; static LSM303AGRAccSensor *accelerometer = mems_expansion_board->accelerometer; +DigitalOut myLed(LED1); + /* Helper function for printing floats & doubles */ static char *print_double(char* str, double v, int decimalDigits=2) { @@ -92,7 +94,7 @@ float value1, value2; char buffer1[32], buffer2[32]; int32_t axes[3]; - + int32_t axes0,axes1; /* Enable all sensors */ hum_temp->enable(); press_temp->enable(); @@ -102,21 +104,22 @@ acc_gyro->enable_g(); printf("\r\n--- Starting new run ---\r\n"); - + /* hum_temp->read_id(&id); - printf("HTS221 humidity & temperature = 0x%X\r\n", id); + printf("HTS221 humidity & temperature = 0x%X\r\n", id); press_temp->read_id(&id); - printf("LPS22HB pressure & temperature = 0x%X\r\n", id); + printf("LPS22HB pressure & temperature = 0x%X\r\n", id); magnetometer->read_id(&id); printf("LSM303AGR magnetometer = 0x%X\r\n", id); accelerometer->read_id(&id); printf("LSM303AGR accelerometer = 0x%X\r\n", id); + */ acc_gyro->read_id(&id); printf("LSM6DSL accelerometer & gyroscope = 0x%X\r\n", id); while(1) { printf("\r\n"); - +/* hum_temp->get_temperature(&value1); hum_temp->get_humidity(&value2); printf("HTS221: [temp] %7s C, [hum] %s%%\r\n", print_double(buffer1, value1), print_double(buffer2, value2)); @@ -132,13 +135,30 @@ accelerometer->get_x_axes(axes); printf("LSM303AGR [acc/mg]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); - +*/ acc_gyro->get_x_axes(axes); printf("LSM6DSL [acc/mg]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); - + /* acc_gyro->get_g_axes(axes); printf("LSM6DSL [gyro/mdps]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); - - wait(1.5); + */ + if((axes[1]>150)||(axes[1]<-150)) + //accendi led + axes1=0; //sbagliato + + else axes1=1; //ok + + if((axes[0]>150)||(axes[0]<-150)) + axes0=0;//sbagliato + + + else axes0=1;//ok + //spegni led + + if(axes0&&axes1) myLed=1; + else myLed=0; + wait(0.5); + + } }