![](/media/cache/profiles/603ec80e671c74a8641d332712c458e8.jpg.50x50_q85.jpg)
Programa exemplo para biblioteca HCSR04
Diff: main.cpp
- Revision:
- 0:b0a3597dffa9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 05 19:04:15 2015 +0000 @@ -0,0 +1,17 @@ +#include "mbed.h" +#include "HCSR04.h" + +DigitalOut myled(LED1); +Serial pc(USBTX,USBRX); + +HCSR04 sonar(A2, D12); + +int main() { + printf("INICIO PROGRAMA\n"); + while(1) { + printf("Distancia detectada pelo sensor Frente %.2f cm \n", sonar.getCm()); + wait_ms(1000); + printf("Distancia detectada pelo sensor Frente %.2f in \n", sonar.getIn()); + wait_ms(1000); + } +} \ No newline at end of file