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 0:423cbb408f32, committed 2014-12-20
- Comitter:
- WAT34
- Date:
- Sat Dec 20 01:05:52 2014 +0000
- Commit message:
- HCSR04;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 20 01:05:52 2014 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +Timer t; +DigitalOut led(LED1); +DigitalOut trig(p21); +DigitalIn echo(p22); +Serial pc(USBTX,USBRX); + +int main(){ + double so; + led = 0; + while(1){ + t.reset(); + trig = 1; + so = 0; + wait_us(10); + trig = 0; + if(echo == 1){ + t.start(); + while(1){ + if(echo == 0){ + t.stop(); + so = t.read(); + so = (so/2.0)*34000.0; + pc.printf("%lf\n\r",so); + break; + } + } + } + led != led ; + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 20 01:05:52 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file