![](/media/cache/group/AET.jpg.50x50_q85.jpg)
primjer mjerenja udaljenosti
Dependencies: mbed
Fork of HC-SR04 by
Revision 1:144bd7bdd1d1, committed 2015-06-12
- Comitter:
- cvitas
- Date:
- Fri Jun 12 16:37:50 2015 +0000
- Parent:
- 0:e7a1440e980a
- Commit message:
- Pomo? uz zadatak 6
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 |
--- a/main.cpp Wed Jan 28 15:17:47 2015 +0000 +++ b/main.cpp Fri Jun 12 16:37:50 2015 +0000 @@ -5,6 +5,7 @@ DigitalOut trig (p25); DigitalIn echo (p6); +DigitalOut led1 (LED1); //Pswitch sw(p8); double pulsedur, distance; Timer tmr; @@ -26,7 +27,12 @@ pulsedur = tmr.read_us(); distance = pulsedur*0.017; //cm - pc.printf("pulsedur=%8.2f\n", distance); - wait(0.3); + pc.printf("pulsedur=%8.2f\n\r", distance); + pc.printf("\n"); + if (distance<4) + led1 =1; + else + led1 =0; + wait(0.5); } }
--- a/mbed.bld Wed Jan 28 15:17:47 2015 +0000 +++ b/mbed.bld Fri Jun 12 16:37:50 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf \ No newline at end of file