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.
Diff: main.cpp
- Revision:
- 0:f07bc5dab40d
- Child:
- 2:656a20620e62
diff -r 000000000000 -r f07bc5dab40d main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Feb 20 20:45:05 2019 +0000
@@ -0,0 +1,45 @@
+#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();
+}
+
\ No newline at end of file