![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Accelero Brindan
Diff: main.cpp
- Revision:
- 1:bcb2d1a61147
- Parent:
- 0:a2a605398a75
- Child:
- 2:59eeb8637e5d
--- a/main.cpp Mon Apr 15 13:54:01 2019 +0000 +++ b/main.cpp Thu May 09 14:43:53 2019 +0000 @@ -1,14 +1,11 @@ -/* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - */ - #include "LSM6DS33.h" #include <stdio.h> #include <stdlib.h> -LSM6DS33 acc = LSM6DS33(I2C_SDA, I2C_SCL); -DigitalIn ComptIncr(PA_8); + +// Definition des variables de l'accéléromètre + +LSM6DS33 acc = LSM6DS33(I2C_SDA, I2C_SCL); //Déclarations des broches pour la communication en I2C float axx0; float ayy0; @@ -40,7 +37,7 @@ int main() { a2 = 0; - k=0; + k = 0; vx = 0; vy = 0; @@ -61,8 +58,6 @@ // On veut que l'accéleration qu'on mesure soit nul, pour cela, nous devons trouver axx0 // le plus précisement possible ( à 10^-2). On pourra alors retrancher axx0 au futur valeur. - //a1 = ComptIncr.read(); - while(abs(epsilonx)>0.001 or abs(epsilony)>0.001) { axx0=axx0+epsilonx; @@ -103,16 +98,16 @@ vy=0; } - if (k== 5) {k=0;}; - tabax[k]=axx1; - tabay[k]=ayy1; - tabvx[k]=vx; - tabvy[k]=vy; - if ( tabax[0]<0.1 && tabax[1]<0.1 && tabax[2]<0.1 && tabax[3]<0.1 && tabax[4]<0.1 && tabvx[0]<0.01 && tabvx[1]<0.01 && tabvx[2]<0.01 && tabvx[3]<0.01 && tabvx[4]<0.01 ) { + if (k == 5) {k=0;}; + tabax[k] = axx1; + tabay[k] = ayy1; + tabvx[k] = vx; + tabvy[k] = vy; + if ( tabax[0]<0.1 && tabax[1]<0.1 && tabax[2]<0.1 && tabax[3]<0.1 && tabax[4]<0.1 && tabvx[0]<0.1 && tabvx[1]<0.1 && tabvx[2]<0.1 && tabvx[3]<0.1 && tabvx[4]<0.1 ) { vx=0; printf("Vitesse en X mis a zero\n"); } - if ( tabay[0]<0.1 && tabay[1]<0.1 && tabay[2]<0.1 && tabay[3]<0.1 && tabay[4]<0.1 && tabvy[0]<0.01 && tabvy[1]<0.01 && tabvy[2]<0.01 && tabvy[3]<0.01 && tabvy[4]<0.01 ) { + if ( tabay[0]<0.1 && tabay[1]<0.1 && tabay[2]<0.1 && tabay[3]<0.1 && tabay[4]<0.1 && tabvy[0]<0.1 && tabvy[1]<0.1 && tabvy[2]<0.1 && tabvy[3]<0.1 && tabvy[4]<0.1 ) { vy=0; printf("Vitesse en Y mis a zero\n"); } @@ -127,8 +122,6 @@ //printf("acceleration en V = %f\n", V); - //a2 = ComptIncr.read(); - //if (a1=a2) } // fin du while