![](/media/cache/profiles/603ec80e671c74a8641d332712c458e8.jpg.50x50_q85.jpg)
Programa exemplo para biblioteca HCSR04
main.cpp@0:b0a3597dffa9, 2015-02-05 (annotated)
- Committer:
- Nestordp
- Date:
- Thu Feb 05 19:04:15 2015 +0000
- Revision:
- 0:b0a3597dffa9
Programa exemplo biblioteca HCSR04
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nestordp | 0:b0a3597dffa9 | 1 | #include "mbed.h" |
Nestordp | 0:b0a3597dffa9 | 2 | #include "HCSR04.h" |
Nestordp | 0:b0a3597dffa9 | 3 | |
Nestordp | 0:b0a3597dffa9 | 4 | DigitalOut myled(LED1); |
Nestordp | 0:b0a3597dffa9 | 5 | Serial pc(USBTX,USBRX); |
Nestordp | 0:b0a3597dffa9 | 6 | |
Nestordp | 0:b0a3597dffa9 | 7 | HCSR04 sonar(A2, D12); |
Nestordp | 0:b0a3597dffa9 | 8 | |
Nestordp | 0:b0a3597dffa9 | 9 | int main() { |
Nestordp | 0:b0a3597dffa9 | 10 | printf("INICIO PROGRAMA\n"); |
Nestordp | 0:b0a3597dffa9 | 11 | while(1) { |
Nestordp | 0:b0a3597dffa9 | 12 | printf("Distancia detectada pelo sensor Frente %.2f cm \n", sonar.getCm()); |
Nestordp | 0:b0a3597dffa9 | 13 | wait_ms(1000); |
Nestordp | 0:b0a3597dffa9 | 14 | printf("Distancia detectada pelo sensor Frente %.2f in \n", sonar.getIn()); |
Nestordp | 0:b0a3597dffa9 | 15 | wait_ms(1000); |
Nestordp | 0:b0a3597dffa9 | 16 | } |
Nestordp | 0:b0a3597dffa9 | 17 | } |