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.
Diff: main.cpp
- Revision:
- 0:a3131d121a8f
- Child:
- 1:4847c54eed20
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 11 04:30:44 2020 +0000 @@ -0,0 +1,29 @@ +//reference from +//https://www.hiramine.com/physicalcomputing/mbed/irreceiver.html + +#include "mbed.h" + +DigitalIn g_dpinIrReceiver(D2); + +Serial g_serial(USBTX, USBRX); + +int main() +{ + g_serial.baud(115200); + + Timer timer; + timer.start(); + int iMicroSec_prev = timer.read_us(); + int iState_prev = 1; + while(1) + { + int iState = g_dpinIrReceiver; + if( iState != iState_prev ) + { + iState_prev = iState; + int iMicroSec = timer.read_us(); + g_serial.printf( "%d, ", iMicroSec - iMicroSec_prev );//hex + iMicroSec_prev = iMicroSec; + } + } +} \ No newline at end of file