超音波センサー

Dependencies:   mbed HCSR

Committer:
tomotsugu
Date:
Mon Jul 13 06:32:47 2020 +0000
Revision:
0:9906eaf16933
distance

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomotsugu 0:9906eaf16933 1 #include "mbed.h"
tomotsugu 0:9906eaf16933 2 #include "hcsr04.h"
tomotsugu 0:9906eaf16933 3
tomotsugu 0:9906eaf16933 4 Serial pc(USBTX, USBRX);
tomotsugu 0:9906eaf16933 5 HCSR04 usensor(p13,p14);
tomotsugu 0:9906eaf16933 6 unsigned int dist;
tomotsugu 0:9906eaf16933 7 int main()
tomotsugu 0:9906eaf16933 8 {
tomotsugu 0:9906eaf16933 9 //unsigned char count=0;
tomotsugu 0:9906eaf16933 10 while(1) {
tomotsugu 0:9906eaf16933 11 usensor.start();
tomotsugu 0:9906eaf16933 12 dist=usensor.get_dist_cm();
tomotsugu 0:9906eaf16933 13 pc.printf("cm:%ld\r\n",dist );
tomotsugu 0:9906eaf16933 14
tomotsugu 0:9906eaf16933 15 //count++;
tomotsugu 0:9906eaf16933 16 //pc.printf("Distance =%d\r\n",count);
tomotsugu 0:9906eaf16933 17
tomotsugu 0:9906eaf16933 18 }
tomotsugu 0:9906eaf16933 19 }