parkingo / Mbed 2 deprecated DISCO-L053C8_UltraSon

Dependencies:   HC_SR04_Ultrasonic_Library mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ultrasonic.h"
00003 
00004 
00005 PinName trig = PA_10;
00006 PinName echo = PA_9;
00007 float updateSpeed = 1; // 1 Hz, 1 fois par sec
00008 float timeout = 2;
00009 
00010 
00011 int mesure = 0;
00012 
00013 int main() 
00014 {
00015     
00016 ultrasonic(trig, echo, updateSpeed, timeout);
00017 
00018     while(1) 
00019     {
00020         mesure = getCurrentDistance();
00021         wait(0.1);
00022         printf("%d\n",mesure);
00023         wait(0.2);
00024     }
00025 }