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

main.cpp

Committer:
Blaze513
Date:
2010-08-22
Revision:
0:3d969e0b4ca0
Child:
1:b533b95e807a

File content as of revision 0:3d969e0b4ca0:

#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);
    }
}