CanSat-C 2021 / Mbed 2 deprecated us015-1

Dependencies:   mbed

FrontGet.h

Committer:
ushiroji
Date:
2021-10-21
Revision:
1:8ebc0fbaa981

File content as of revision 1:8ebc0fbaa981:

#include "us015.h"

US015 hs(D2, D3);
DigitalOut Ultra(D2);
Serial pc(USBTX,USBRX); 

int FrontGet() {
        Ultra = 1;  //超音波on
        hs.TrigerOut();
        wait(1);
        int distance;
        distance = hs.GetDistance();
        pc.printf("distance=%d\r\n", distance);  //距離出力
        Ultra=0;//超音波off
        return distance;
}