Lehrer Busch
/
xxx_Sonar-HC-SR04
xxx_Sonar-HC-SR04
main.cpp@1:1e73871289d7, 2022-02-23 (annotated)
- Committer:
- itbusch
- Date:
- Wed Feb 23 19:20:31 2022 +0000
- Revision:
- 1:1e73871289d7
- Parent:
- 0:b0a3597dffa9
xxx_Sonar-HC-SR04
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 | |
itbusch | 1:1e73871289d7 | 7 | HCSR04 sonar(D2, D4); //Trigger, Echo |
Nestordp | 0:b0a3597dffa9 | 8 | |
Nestordp | 0:b0a3597dffa9 | 9 | int main() { |
Nestordp | 0:b0a3597dffa9 | 10 | printf("INICIO PROGRAMA\n"); |
Nestordp | 0:b0a3597dffa9 | 11 | while(1) { |
itbusch | 1:1e73871289d7 | 12 | printf("Distanz %.2f cm \n\r", sonar.getCm()); |
itbusch | 1:1e73871289d7 | 13 | pc.printf("Distancia %.2f cm \n\r",sonar.getCm()); |
Nestordp | 0:b0a3597dffa9 | 14 | wait_ms(1000); |
Nestordp | 0:b0a3597dffa9 | 15 | } |
Nestordp | 0:b0a3597dffa9 | 16 | } |