xxx_Sonar-HC-SR04

Dependencies:   mbed HC-SR04

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?

UserRevisionLine numberNew 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 }