春ロボ ロケット団 / Mbed 2 deprecated testultrasonic

Dependencies:   mbed hcsr04

main.cpp

Committer:
maxnagazumi
Date:
2020-03-02
Revision:
0:ee90d231a709

File content as of revision 0:ee90d231a709:

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

HCSR04 echo_1(PC_0,PC_12);//A
HCSR04 echo_2(PA_15,PB_7);//A
HCSR04 echo_3(PH_1,PB_0);// B
HCSR04 echo_4(PC_3,PB_10);//B 

int main() {
    
    printf("100");
    
    double a=0,b=0,c=0,d=0;
    while(1) {
       echo_1.start();
        echo_2.start();
        echo_3.start();
        echo_4.start();
        wait(1);//minimum wait is 30msec 
        a=echo_1.get_dist_cm();
        b=echo_2.get_dist_cm();
       c=echo_3.get_dist_cm();
        d=echo_4.get_dist_cm();
        printf("a:%lf b:%lf c:%lf d:%lf\r\n",a,b,c,d);
    }
}