The Nucleo Distance Calculator Simple code to use HCSR04 and nokia 5110 to display distance and ring a buzzer when the distance is lower than a certain threshold.

Dependencies:   N5110 NOKIA_5110 mbed

Fork of UltraTest by stephen smitherman

Revision:
0:f91b4b2acbe1
Child:
1:56e6200a897b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 11 21:20:40 2014 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "HCSR04.h"
+
+DigitalOut myled(LED1);
+Serial pc(USBTX,USBRX);
+HCSR04 ultra(p12,p11);
+
+float range=0;
+
+int main() {
+    
+        
+    pc.printf("Program Start\n");    
+    while(1) {
+        
+        ultra.startMeas();
+        
+        wait(0.2);
+        
+        
+        if( ultra.getMeas(range) == RANGE_MEAS_VALID)
+        {
+            pc.printf("Range - %f\n\r",  range);
+        }
+    }
+}