敦哉 品川
/
HC-SR04
超音波センサー
Revision 0:69ac1abc8193, committed 2019-12-25
- Comitter:
- shina
- Date:
- Wed Dec 25 06:21:20 2019 +0000
- Commit message:
- HC-SR04
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HCSR04.lib Wed Dec 25 06:21:20 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/2019NHK_teamA/code/HCSR04/#095071ae3cac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 25 06:21:20 2019 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +#include "hcsr04.h" + +Serial pc(USBTX,USBRX); +DigitalOut led(LED1); +HCSR04 usensor(D4,D6); + +unsigned int dist; + +int main(){ + usensor.set_temperature(15); + while(true){ + usensor.start(); + wait_ms(100); + dist=usensor.get_dist_cm(); + pc.printf("%dmm\n",dist*10); + if(dist<100){ + led=1; + }else{ + led=0; + } + } + } + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 25 06:21:20 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file