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
main.cpp
- Committer:
- YUPPY
- Date:
- 2019-11-28
- Revision:
- 4:7cffa8775a27
- Parent:
- 3:f7f92004d3ac
File content as of revision 4:7cffa8775a27:
#include "mbed.h" #include "us015.h" DigitalOut myled(LED1); US015 hs(p12,p11); DigitalIn thermo(p20); DigitalOut Sb612switch(p15); DigitalOut Ultra(p12); Serial pc(USBTX,USBRX); // tx, rx int main(){ float th; Timer tm; pc.printf("start\r\n"); Sb612switch=0; //焦電off printf("焦電Off\r\n"); Ultra=1;//超音波on printf("超音波On\r\n"); while(1) { hs.TrigerOut(); wait(1); int distance; distance = hs.GetDistance(); printf("distance=%d\r\n",distance);//距離出力 if(distance<=2000){//超音波反応 Ultra=0;//超音波off Sb612switch=1;//焦電on bool detected=false; th = thermo; if(th==1 && !detected) {//焦電反応ありの場合 detected=true; pc.printf("human\r\n"); tm.reset(); tm.start(); } else{//焦電反応なしの場合 printf("not found\r\n"); Sb612switch=0; Ultra=1; detected=false; } }if(distance>2000){//超音波反応遠い printf("distance>2000だぞ\r\n"); } //while(1) } return 0; }