Display text on screen.

Dependencies:   TextLCD mbed MaxSonar RTC-DS1307

Fork of TextLCD_HelloWorld by Simon Ford

Revision:
6:fa30f8383b99
Parent:
5:2f13ec8efe0b
Child:
7:f00ddf85cacc
--- a/main.cpp	Wed May 24 13:51:44 2017 +0000
+++ b/main.cpp	Wed May 24 14:08:30 2017 +0000
@@ -20,6 +20,9 @@
     
     MaxSonar *range1;
     float r1;
+    
+    MaxSonar *range2;
+    float r2;
  
     // Create and configure object for 3.3V powered LV-series device, 
     // accessed with analog reads (in cm) on p16, triggered by p7.
@@ -27,7 +30,9 @@
     range1->setVoltage(3.3);
     range1->setUnits(MS_CM);
     
-    
+    range2 = new MaxSonar(MS_LV, MS_ANALOG, PTB9, PTB3);
+    range2->setVoltage(3.3);
+    range2->setUnits(MS_CM);
  
     while(1) {
         // Trigger read, wait 49ms until ranger finder has
@@ -35,11 +40,18 @@
         range1->triggerRead();
         wait_ms(49);
         r1 = range1->read();
+        
+        range2->triggerRead();
+        wait_ms(49);
+        r2 = range2->read();
       
         // Print and delay 0.5s.
-        char str[1024];
-        sprintf (str, "Range: %.3f cm\n", r1);
-        UpdateScreen(screen2, str);
+        char range1_char_array[1024];
+        char range2_char_array[1024];
+        sprintf (range1_char_array, "Range: %.3f cm\n", r1);
+        sprintf (range2_char_array, "Range: %.3f cm\n", r2);
+        UpdateScreen(screen1, range1_char_array);
+        UpdateScreen(screen2, range2_char_array);
         
         wait(0.5);
     }