超音波センサー

Dependencies:   mbed HCSR

main.cpp

Committer:
tomotsugu
Date:
2020-07-13
Revision:
0:9906eaf16933

File content as of revision 0:9906eaf16933:

#include "mbed.h"
#include "hcsr04.h"

Serial pc(USBTX, USBRX);
HCSR04  usensor(p13,p14);
unsigned int dist;
int main()
{
    //unsigned char count=0;
    while(1) {
        usensor.start();
        dist=usensor.get_dist_cm();
        pc.printf("cm:%ld\r\n",dist );
 
        //count++;
        //pc.printf("Distance =%d\r\n",count);
        
    }
}