Luis Silvio Cordova Rivadeneira
/
Ultrasonic_Sensor
Ejemplo para entender funcionamiento del sensor Ultrasonico HCSR04
Revision 3:3e528b02b8d7, committed 2020-02-05
- Comitter:
- lscordovar
- Date:
- Wed Feb 05 17:04:20 2020 +0000
- Parent:
- 2:287be83ed6a0
- Commit message:
- actualizacion;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 287be83ed6a0 -r 3e528b02b8d7 main.cpp --- a/main.cpp Tue Feb 04 19:12:35 2020 +0000 +++ b/main.cpp Wed Feb 05 17:04:20 2020 +0000 @@ -5,14 +5,16 @@ DigitalOut GREEN(PD_12); DigitalOut ORANGE(PD_13); - +Serial device(PA_2,PA_3); int main() { + device.baud(115200); + device.printf("Start\n"); while(1) { long d = sensor.distance(1); - printf("Distancia:%d ",sensor.distance(1)); + device.printf("Distancia:%i \r\n",sensor.distance(1)); if(d<=10) { GREEN = 0; @@ -27,7 +29,7 @@ ORANGE = 0; GREEN=0; } - + wait(0.1); } }