Dev Joshi
/
SRF02_libv2
Library for the SRF02 ultrasonic rangefinder
main.cpp
- Committer:
- go2dev
- Date:
- 2011-07-10
- Revision:
- 0:862f11d627f9
File content as of revision 0:862f11d627f9:
//Useage example for the SRF02 Library #include "mbed.h" #include "SRF02.h" Serial debugport(USBTX,USBRX); SRF02 mySensor(p9,p10,0xE0); main() { time_t seconds = time(NULL); //Internal RTC debugport.baud(115200); //set the buadrate (default is 9600 if this command is not used) debugport.format(8,Serial::None,1); //config the serial port (default is 8N1) debugport.printf("Hello World! %d \r\n", seconds); //send a message out of the serial port to check all is well //include a time stamp for reference (seconds since power up) while (1) { debugport.printf("current distance: %.2f cm. (v2) \r\n", mySensor.measurecm()); debugport.printf("current distance: %.2f inches.\r\n", mySensor.measurein()); debugport.printf("current flightime: %.2f microseconds.\r\n", mySensor.measureus()); } }