ping test

Dependencies:   mbed Ping

Committer:
jasonberry
Date:
Tue Feb 02 13:46:38 2021 +0000
Revision:
0:3898412e9440
ping hello world

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jasonberry 0:3898412e9440 1 // Continuously send pings and read the sensor
jasonberry 0:3898412e9440 2 #include "mbed.h"
jasonberry 0:3898412e9440 3 #include "Ping.h"
jasonberry 0:3898412e9440 4
jasonberry 0:3898412e9440 5 Ping Pinger(p21);
jasonberry 0:3898412e9440 6 Serial pc(USBTX, USBRX); // tx, rx
jasonberry 0:3898412e9440 7
jasonberry 0:3898412e9440 8 int main()
jasonberry 0:3898412e9440 9 {
jasonberry 0:3898412e9440 10 int range;
jasonberry 0:3898412e9440 11
jasonberry 0:3898412e9440 12 pc.printf("Hello World ping test!\n");
jasonberry 0:3898412e9440 13 while(1)
jasonberry 0:3898412e9440 14 {
jasonberry 0:3898412e9440 15 Pinger.Send();
jasonberry 0:3898412e9440 16 wait_ms(30);
jasonberry 0:3898412e9440 17 range = Pinger.Read_cm();
jasonberry 0:3898412e9440 18 pc.printf("$%d;",range);
jasonberry 0:3898412e9440 19 }
jasonberry 0:3898412e9440 20 }