programme capteur de son pour le drone

Dependencies:   mbed

Committer:
legrandpaul
Date:
Fri Jun 18 15:26:46 2021 +0000
Revision:
0:d021e65ffc99
programme capteur de son

Who changed what in which revision?

UserRevisionLine numberNew contents of line
legrandpaul 0:d021e65ffc99 1 #include "mbed.h"
legrandpaul 0:d021e65ffc99 2 #define N 100
legrandpaul 0:d021e65ffc99 3
legrandpaul 0:d021e65ffc99 4 Serial pc(USBTX, USBRX); // tx, rx
legrandpaul 0:d021e65ffc99 5
legrandpaul 0:d021e65ffc99 6 //const int pin_SS=A0;
legrandpaul 0:d021e65ffc99 7 AnalogIn pin_SS(A1);
legrandpaul 0:d021e65ffc99 8 float valeur,v_son;
legrandpaul 0:d021e65ffc99 9
legrandpaul 0:d021e65ffc99 10
legrandpaul 0:d021e65ffc99 11 int main(){
legrandpaul 0:d021e65ffc99 12 double tab[N];
legrandpaul 0:d021e65ffc99 13 double max = 0;
legrandpaul 0:d021e65ffc99 14
legrandpaul 0:d021e65ffc99 15 while(1){
legrandpaul 0:d021e65ffc99 16
legrandpaul 0:d021e65ffc99 17 for (int i=0;i<N;i++){
legrandpaul 0:d021e65ffc99 18 tab[i]= pin_SS.read();;
legrandpaul 0:d021e65ffc99 19 }
legrandpaul 0:d021e65ffc99 20
legrandpaul 0:d021e65ffc99 21 max = tab[0];
legrandpaul 0:d021e65ffc99 22 for (int j=1;j<N;j++)
legrandpaul 0:d021e65ffc99 23 {
legrandpaul 0:d021e65ffc99 24 if(tab[j]>=max) max = tab[j];
legrandpaul 0:d021e65ffc99 25 }
legrandpaul 0:d021e65ffc99 26
legrandpaul 0:d021e65ffc99 27 pc.printf("max : %f\n\n \r",max*1000);
legrandpaul 0:d021e65ffc99 28 wait(0.1);
legrandpaul 0:d021e65ffc99 29
legrandpaul 0:d021e65ffc99 30 }
legrandpaul 0:d021e65ffc99 31 }