SRF02 Ultrasonic range finder library

Dependencies:   mbed

main.cpp

Committer:
go2dev
Date:
2011-05-02
Revision:
0:f0cf55dd23f6

File content as of revision 0:f0cf55dd23f6:

#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.\r\n", mySensor.distancecm());
         debugport.printf("current distance: %.2f inches.\r\n", mySensor.distancein());
         debugport.printf("current flightime: %.2f microseconds.\r\n", mySensor.distanceus());
        
    }
}