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.
main.cpp@0:a3131d121a8f, 2020-02-11 (annotated)
- Committer:
- gitakichi
- Date:
- Tue Feb 11 04:30:44 2020 +0000
- Revision:
- 0:a3131d121a8f
- Child:
- 1:4847c54eed20
Moved, next is to judge the key and send the judgment result serially
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gitakichi | 0:a3131d121a8f | 1 | //reference from |
gitakichi | 0:a3131d121a8f | 2 | //https://www.hiramine.com/physicalcomputing/mbed/irreceiver.html |
gitakichi | 0:a3131d121a8f | 3 | |
gitakichi | 0:a3131d121a8f | 4 | #include "mbed.h" |
gitakichi | 0:a3131d121a8f | 5 | |
gitakichi | 0:a3131d121a8f | 6 | DigitalIn g_dpinIrReceiver(D2); |
gitakichi | 0:a3131d121a8f | 7 | |
gitakichi | 0:a3131d121a8f | 8 | Serial g_serial(USBTX, USBRX); |
gitakichi | 0:a3131d121a8f | 9 | |
gitakichi | 0:a3131d121a8f | 10 | int main() |
gitakichi | 0:a3131d121a8f | 11 | { |
gitakichi | 0:a3131d121a8f | 12 | g_serial.baud(115200); |
gitakichi | 0:a3131d121a8f | 13 | |
gitakichi | 0:a3131d121a8f | 14 | Timer timer; |
gitakichi | 0:a3131d121a8f | 15 | timer.start(); |
gitakichi | 0:a3131d121a8f | 16 | int iMicroSec_prev = timer.read_us(); |
gitakichi | 0:a3131d121a8f | 17 | int iState_prev = 1; |
gitakichi | 0:a3131d121a8f | 18 | while(1) |
gitakichi | 0:a3131d121a8f | 19 | { |
gitakichi | 0:a3131d121a8f | 20 | int iState = g_dpinIrReceiver; |
gitakichi | 0:a3131d121a8f | 21 | if( iState != iState_prev ) |
gitakichi | 0:a3131d121a8f | 22 | { |
gitakichi | 0:a3131d121a8f | 23 | iState_prev = iState; |
gitakichi | 0:a3131d121a8f | 24 | int iMicroSec = timer.read_us(); |
gitakichi | 0:a3131d121a8f | 25 | g_serial.printf( "%d, ", iMicroSec - iMicroSec_prev );//hex |
gitakichi | 0:a3131d121a8f | 26 | iMicroSec_prev = iMicroSec; |
gitakichi | 0:a3131d121a8f | 27 | } |
gitakichi | 0:a3131d121a8f | 28 | } |
gitakichi | 0:a3131d121a8f | 29 | } |