
works with masterboard.
Revision 0:838bb871a4d1, committed 2013-05-03
- Comitter:
- zenglingxuan
- Date:
- Fri May 03 11:16:26 2013 +0000
- Commit message:
- detect whether the person is sit. range finder. works
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 Fri May 03 11:16:26 2013 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" + +Serial xbee1(PTC4, PTC3); //xbee +DigitalOut rst1(PTC5); + +AnalogIn dis(PTB0); //range finder +DigitalOut myled(LED1); + +int main() { + + int per; //range per + char f; //range flag + int l; //led indicator + + + // reset the xbees (at least 200ns) + rst1 = 0; + wait_ms(1); + rst1 = 1; + wait_ms(1); + + + while(1) { + //cal distance and set flag when close enough + per=dis*512/3.3; + if (per<3){ + f='1'; + l=0; + } + else { + f='0'; + l=1; + } + myled=l; + + xbee1.putc(f); + + wait(1); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 03 11:16:26 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd \ No newline at end of file