Interface class for the Max Botix ultrasonic range finder model 1210. It includes input methods for PWM, Analog, and Serial. A PwmIn class was created to allow the PWM input to be read. Now includes automatic range update via interrupts.

Dependencies:   mbed

Revision:
0:3d969e0b4ca0
Child:
1:b533b95e807a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Aug 22 21:18:20 2010 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+#include "MB1210.h"
+
+DigitalOut debugled(LED1);
+Serial Computer(USBTX, USBRX);
+
+MB1210 RangeFinder(p12, p15, p13, p14);
+
+int main()
+{
+    Computer.baud(9600);
+    debugled = 0;
+    RangeFinder.Unit(39.370);//change units to inches
+    RangeFinder.Voltage(5);
+    while(1)
+    {
+        debugled = !debugled;
+        RangeFinder.RequestSyncRead();//request a range reading
+        wait_ms(100);//wait for reading to be prepared
+        RangeFinder.Mode(0);//switch to PWM mode
+        Computer.printf("PWM reading: %f in | ", RangeFinder.Read());
+        RangeFinder.Mode(1);//switch to Analog mode
+        Computer.printf("Analog reading: %f in | ", RangeFinder.Read());
+        RangeFinder.Mode(2);//switch to serial mode
+        Computer.printf("Serial reading: %f in | ", RangeFinder.Read());
+        wait(0.9);
+    }
+}
\ No newline at end of file