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-28
- Revision:
- 4:a615b75d4126
- Parent:
- 1:b533b95e807a
File content as of revision 4:a615b75d4126:
#include "mbed.h" #include "MB1210.h" DigitalOut debugled(LED1); Serial Computer(USBTX, USBRX); MB1210 RangeFinder(p12, p15, p13, p14); float Range; int main() { Computer.baud(9600); debugled = 0; RangeFinder.Unit(39.370);//change units to inches RangeFinder.AttachInterruptBuffer(&Range); RangeFinder.Mode(0x0A); 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 | ", Range); //RangeFinder.Mode(1);//switch to Analog mode //Computer.printf("Analog reading: %f in | ", Range); //RangeFinder.Mode(2);//switch to serial mode Computer.printf("Serial reading: %f in | ", Range); wait(0.9); } }