Nobuki HIRAMINE
/
irreceiver2
IR Receiver
Revision 0:d8a26e89c7f3, committed 2015-08-12
- Comitter:
- nobuki
- Date:
- Wed Aug 12 17:23:22 2015 +0000
- Commit message:
- a
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 d8a26e89c7f3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 12 17:23:22 2015 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" + +DigitalIn g_digitalinIrReceiver(p20); +Serial g_serial(USBTX, USBRX); + +int main() +{ + // デジタル入力ピンは、デフォルトで、内部プルダウンとなります(参考:https://developer.mbed.org/handbook/DigitalIn) + // 内部プルダウンの場合、IRセンサーからのHIGH電圧をLOW電圧と検知してしまうので、内部プルモードを「プルなし(PullNone)」にします。 + g_digitalinIrReceiver.mode( PullNone ); // mode : PullUp, PullDown, PullNone, OpenDrain + g_serial.baud(115200); + + Timer timer; + timer.start(); + int iMicroSec_prev = timer.read_us(); + int iState_prev = 1; + while(1) + { + int iState = g_digitalinIrReceiver; + if( iState != iState_prev ) + { + iState_prev = iState; + int iMicroSec = timer.read_us(); + g_serial.printf( "%d, ", iMicroSec - iMicroSec_prev ); + iMicroSec_prev = iMicroSec; + } + } +}
diff -r 000000000000 -r d8a26e89c7f3 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 12 17:23:22 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7 \ No newline at end of file