Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- Nilox
- Date:
- 2019-02-20
- Revision:
- 0:f07bc5dab40d
- Child:
- 2:656a20620e62
File content as of revision 0:f07bc5dab40d:
#include "mbed.h"
#include <PwmIn.h>
DigitalIn mybutton(USER_BUTTON);
DigitalOut trig(PA_10);
Serial pc(USBTX,USBRX);
PwmIn LidarI(PB_3);
float mes = 0;
int arret=0,n=0,i=0;
float boucleM(){
wait_ms(10);
mes = LidarI.pulsewidth();
if(mes!=0){
pc.printf("Mesure : %1.2f\n",mes/10);
} else pc.printf("Erreur : valeur nulles.\n");
arret = !mybutton.read();
return (mes/10);
}
int main() {
pc.printf("\nLancement du programme...\n");
pc.printf("Combien de mesures allez-vous prendre ?\n");
pc.scanf("%d",&n);
pc.printf("%d\n\n",n);
float tabM[n];
trig = 1;
trig=0;
wait_us(500);
while(i<n){
tabM[i]=boucleM();
i++;
}
i=0;
while(i<n){
pc.printf("M(%d):[%f]\n",i,tabM[i]);
i=i++;
}
pc.printf("Arret du programme...");
sleep();
}