flapping wing
/
Nucleo_IR_Receiver_sample
IR Receiver demo for Nucleo F303K8
Revision 0:0ebc440826c6, committed 2016-09-23
- Comitter:
- flappingwing
- Date:
- Fri Sep 23 07:20:49 2016 +0000
- Commit message:
- IR receiver demo for Nucleo F303K8
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 |
diff -r 000000000000 -r 0ebc440826c6 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 23 07:20:49 2016 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +DigitalIn di(D2); +Serial ser(USBTX, USBRX); + +int main() +{ + di.mode( PullNone ); // mode : PullUp, PullDown, PullNone, OpenDrain + ser.baud(115200); + + Timer timer; + timer.start(); + int iMicroSec_prev = timer.read_us(); + int iState_prev = 1; + while(1) + { + int iState = di; + if( iState != iState_prev ) + { + iState_prev = iState; + int iMicroSec = timer.read_us(); + ser.printf( "%d, ", iMicroSec - iMicroSec_prev ); + iMicroSec_prev = iMicroSec; + } + } +}
diff -r 000000000000 -r 0ebc440826c6 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 23 07:20:49 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85 \ No newline at end of file