fd

Dependencies:   HCSR04 mbed

Fork of STMNucleoF401RE_ExampleCode_13_Ultasound by Corso Rapid Prototyping with STM32Nucleo

Files at this revision

API Documentation at this revision

Comitter:
perlatecnica
Date:
Mon Nov 02 14:24:27 2015 +0000
Commit message:
v1.0

Changed in this revision

HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a4f31fdfb261 HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Mon Nov 02 14:24:27 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/prabhuvd/code/HCSR04/#71da0dbf4400
diff -r 000000000000 -r a4f31fdfb261 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 02 14:24:27 2015 +0000
@@ -0,0 +1,32 @@
+/****************************************************
+*            FAST PROTOTYPING WITH NUCLEO           *
+* Example Code 13: Ultrasound HCSR04                *
+* Author: Mauro D'Angelo                            *
+* Organization: Perlatecnica no-profit organization *  
+*****************************************************/
+
+#include "mbed.h"
+#include "hcsr04.h"
+
+// Instanzio un oggetto di tipo HCSR04 ed assegno i pin di trigger e di echo 
+HCSR04 sensor(PB_8, PB_9);
+
+// Serial
+Serial pc(USBTX, USBRX);
+ 
+int main() {
+    // Fisso il baudrate
+    pc.baud(9600);
+    
+    // Main loop
+    while(1) {
+        // Avvia un impulso della durata di 10us sul pin di trigger
+        sensor.start();
+        
+        // Aspetta prima della prossima lettura
+        wait_ms(100); 
+        
+        // Stampa sulla seriale la misura della distanza in cm
+        pc.printf("%dcm\r\n", sensor.get_dist_cm());
+    }
+}
diff -r 000000000000 -r a4f31fdfb261 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 02 14:24:27 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file