Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:2acb3f965991
- Child:
- 1:d174c4427e69
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 13 05:12:54 2019 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" +#include "us015.h" +DigitalOut myled(LED1); +US015 hs(p12,p11); +DigitalOut thermo(p20); +DigitalOut Ultra(p12); +Serial pc(USBTX, USBRX); // tx, rx + +int main(){ + float th; + Timer tm; + pc.baud(115200); + pc.printf("start\r\n"); + + bool detected=false; + thermo=0; //焦電off + Ultra=1;//超音波on + + while(1) { + hs.TrigerOut(); + wait(1); + int distance; + distance = hs.GetDistance(); + printf("%d\r\n",distance);//距離出力 + + if(distance<200){//超音波反応 + Ultra=0;//超音波off + thermo=1;//焦電on + if(true) + th = thermo; + if(th=1 && !detected) {//焦電反応ありの場合 + detected=true; + pc.printf("human\r\n"); + tm.reset(); + tm.start(); + }else{//焦電反応なしの場合 + detected=false; + } + +} + //while(true) + } + } + \ No newline at end of file