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
Revision 4:7cffa8775a27, committed 2019-11-28
- Comitter:
- YUPPY
- Date:
- Thu Nov 28 08:05:11 2019 +0000
- Parent:
- 3:f7f92004d3ac
- Commit message:
- yeah
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Nov 28 06:53:24 2019 +0000
+++ b/main.cpp Thu Nov 28 08:05:11 2019 +0000
@@ -2,7 +2,8 @@
#include "us015.h"
DigitalOut myled(LED1);
US015 hs(p12,p11);
-DigitalOut thermo(p20);
+DigitalIn thermo(p20);
+DigitalOut Sb612switch(p15);
DigitalOut Ultra(p12);
Serial pc(USBTX,USBRX); // tx, rx
@@ -10,7 +11,7 @@
float th;
Timer tm;
pc.printf("start\r\n");
- thermo=0; //焦電off
+ Sb612switch=0; //焦電off
printf("焦電Off\r\n");
Ultra=1;//超音波on
printf("超音波On\r\n");
@@ -25,9 +26,9 @@
if(distance<=2000){//超音波反応
Ultra=0;//超音波off
- thermo=1;//焦電on
+ Sb612switch=1;//焦電on
bool detected=false;
- if(true){
+
th = thermo;
if(th==1 && !detected) {//焦電反応ありの場合
detected=true;
@@ -35,16 +36,14 @@
tm.reset();
tm.start();
}
- else if(tm.read_ms()>5000){//焦電反応なしの場合
+ else{//焦電反応なしの場合
printf("not found\r\n");
- thermo=0;
- printf("焦電OFF\r\n");
+ Sb612switch=0;
Ultra=1;
- printf("超音波ONっすよ!\r\n");
detected=false;
}
- }//if(true)
+
}if(distance>2000){//超音波反応遠い
printf("distance>2000だぞ\r\n");
}