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.
main.cpp
- Committer:
- Blaze513
- Date:
- 2010-08-26
- Revision:
- 3:05183e50a923
- Parent:
- 1:b533b95e807a
- Child:
- 4:a615b75d4126
File content as of revision 3:05183e50a923:
#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 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); } }