cansat_B 2019 / Mbed 2 deprecated US015sb612Completed_renewal

Dependencies:   mbed

Committer:
KINU
Date:
Wed Nov 13 05:12:54 2019 +0000
Revision:
0:2acb3f965991
Child:
1:d174c4427e69
US015sb612 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KINU 0:2acb3f965991 1 #include "mbed.h"
KINU 0:2acb3f965991 2 #include "us015.h"
KINU 0:2acb3f965991 3 DigitalOut myled(LED1);
KINU 0:2acb3f965991 4 US015 hs(p12,p11);
KINU 0:2acb3f965991 5 DigitalOut thermo(p20);
KINU 0:2acb3f965991 6 DigitalOut Ultra(p12);
KINU 0:2acb3f965991 7 Serial pc(USBTX, USBRX); // tx, rx
KINU 0:2acb3f965991 8
KINU 0:2acb3f965991 9 int main(){
KINU 0:2acb3f965991 10 float th;
KINU 0:2acb3f965991 11 Timer tm;
KINU 0:2acb3f965991 12 pc.baud(115200);
KINU 0:2acb3f965991 13 pc.printf("start\r\n");
KINU 0:2acb3f965991 14
KINU 0:2acb3f965991 15 bool detected=false;
KINU 0:2acb3f965991 16 thermo=0; //焦電off
KINU 0:2acb3f965991 17 Ultra=1;//超音波on
KINU 0:2acb3f965991 18
KINU 0:2acb3f965991 19 while(1) {
KINU 0:2acb3f965991 20 hs.TrigerOut();
KINU 0:2acb3f965991 21 wait(1);
KINU 0:2acb3f965991 22 int distance;
KINU 0:2acb3f965991 23 distance = hs.GetDistance();
KINU 0:2acb3f965991 24 printf("%d\r\n",distance);//距離出力
KINU 0:2acb3f965991 25
KINU 0:2acb3f965991 26 if(distance<200){//超音波反応
KINU 0:2acb3f965991 27 Ultra=0;//超音波off
KINU 0:2acb3f965991 28 thermo=1;//焦電on
KINU 0:2acb3f965991 29 if(true)
KINU 0:2acb3f965991 30 th = thermo;
KINU 0:2acb3f965991 31 if(th=1 && !detected) {//焦電反応ありの場合
KINU 0:2acb3f965991 32 detected=true;
KINU 0:2acb3f965991 33 pc.printf("human\r\n");
KINU 0:2acb3f965991 34 tm.reset();
KINU 0:2acb3f965991 35 tm.start();
KINU 0:2acb3f965991 36 }else{//焦電反応なしの場合
KINU 0:2acb3f965991 37 detected=false;
KINU 0:2acb3f965991 38 }
KINU 0:2acb3f965991 39
KINU 0:2acb3f965991 40 }
KINU 0:2acb3f965991 41 //while(true)
KINU 0:2acb3f965991 42 }
KINU 0:2acb3f965991 43 }
KINU 0:2acb3f965991 44