Dev Joshi / Mbed 2 deprecated SRF02_lib

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SRF02.h"
00003 
00004 
00005 Serial debugport(USBTX,USBRX);
00006 SRF02 mySensor(p9,p10,0xE0);
00007 
00008 
00009 
00010 
00011 main() {
00012     
00013     time_t seconds = time(NULL); //Internal RTC
00014     debugport.baud(115200); //set the buadrate (default is 9600 if this command is not used)
00015     debugport.format(8,Serial::None,1); //config the serial port (default is 8N1)
00016     debugport.printf("Hello World! %d \r\n", seconds); //send a message out of the serial port to check all is well
00017     //include a time stamp for reference (seconds since power up)
00018    
00019    
00020     while (1) {
00021     
00022         
00023          debugport.printf("current distance: %.2f cm.\r\n", mySensor.distancecm());
00024          debugport.printf("current distance: %.2f inches.\r\n", mySensor.distancein());
00025          debugport.printf("current flightime: %.2f microseconds.\r\n", mySensor.distanceus());
00026         
00027     }
00028 }