ping test

Dependencies:   mbed Ping

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Continuously send pings and read the sensor
00002 #include "mbed.h"
00003 #include "Ping.h"
00004  
00005 Ping Pinger(p21);
00006 Serial pc(USBTX, USBRX); // tx, rx
00007   
00008 int main() 
00009 {
00010  int range;
00011  
00012  pc.printf("Hello World ping test!\n");
00013  while(1) 
00014     {
00015     Pinger.Send();    
00016     wait_ms(30);
00017     range = Pinger.Read_cm();
00018     pc.printf("$%d;",range);
00019     }
00020 }