Trying to use maxsonar ez ae mb1300 with lpc1768

Dependencies:   mbed

Fork of MaxSonar_EZ1_Analog by Michael Shimniok

Files at this revision

API Documentation at this revision

Comitter:
pinguimmaxi
Date:
Fri May 05 11:27:34 2017 +0000
Parent:
0:9dfac5da16a9
Commit message:
hi

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 9dfac5da16a9 -r d91cac1628f9 main.cpp
--- a/main.cpp	Tue Jan 25 00:05:16 2011 +0000
+++ b/main.cpp	Fri May 05 11:27:34 2017 +0000
@@ -17,21 +17,17 @@
 Serial pc(USBTX, USBRX); // tx, rx
 
 int main() {
-    float adc, volts, inches;
-    int feet, in;
+    float adc, volts, cent;
     
-    pc.baud(115200);
+    pc.baud(9600);
     
     while (1){
         adc = ain.read();           // read analog as a float
         volts = adc * 3.3;          // convert to volts
-        inches = volts / 0.0064;    // 3.3V supply: 6.4mV per inch
-        feet = (int) inches / 12;   // inches to feet (trunc)
-        in = (int) inches % 12;     // remainder -> in(ches)
+        cent = volts / 0.0032;    // 3.3V supply: 3.2mV per centimeter
         
-        pc.printf("%8.2f adc %8.2fV %8.2f in %d'%d\"\n", adc, volts, inches, feet, in);
-
-        wait(0.05);                 // 20Hz update rate ; note we aren't truly synchronized to the device or anything...   
+        pc.printf("%f adc - %f cent \n", adc, cent);
+        wait(2);                 // 20Hz update rate ; note we aren't truly synchronized to the device or anything...   
     }
 }