chris stevens
/
IRDARX
ir receiver dremo for tsmp1138
main.cpp@0:f6c1b087dd68, 2014-05-21 (annotated)
- Committer:
- cstevens
- Date:
- Wed May 21 11:32:55 2014 +0000
- Revision:
- 0:f6c1b087dd68
ir receiver for tsmp1138
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cstevens | 0:f6c1b087dd68 | 1 | #include "mbed.h" |
cstevens | 0:f6c1b087dd68 | 2 | |
cstevens | 0:f6c1b087dd68 | 3 | DigitalOut myled(LED1); |
cstevens | 0:f6c1b087dd68 | 4 | Serial pc(USBTX,USBRX); |
cstevens | 0:f6c1b087dd68 | 5 | Serial IRTX(PTC4,PTC3); // TX,RX |
cstevens | 0:f6c1b087dd68 | 6 | DigitalOut Ipower(PTC12); // pin to power the irda |
cstevens | 0:f6c1b087dd68 | 7 | |
cstevens | 0:f6c1b087dd68 | 8 | int main() { |
cstevens | 0:f6c1b087dd68 | 9 | // power the irda electronics on |
cstevens | 0:f6c1b087dd68 | 10 | int i=0; |
cstevens | 0:f6c1b087dd68 | 11 | char string[64]; |
cstevens | 0:f6c1b087dd68 | 12 | Ipower=1; |
cstevens | 0:f6c1b087dd68 | 13 | for(i=0;i<5;i++) |
cstevens | 0:f6c1b087dd68 | 14 | { |
cstevens | 0:f6c1b087dd68 | 15 | myled=0; |
cstevens | 0:f6c1b087dd68 | 16 | pc.printf("Waiting %d\n\r",i); |
cstevens | 0:f6c1b087dd68 | 17 | if(IRTX.readable()){ |
cstevens | 0:f6c1b087dd68 | 18 | IRTX.scanf("%s",string); |
cstevens | 0:f6c1b087dd68 | 19 | pc.printf("%s\n\r",string); |
cstevens | 0:f6c1b087dd68 | 20 | } |
cstevens | 0:f6c1b087dd68 | 21 | myled=1; |
cstevens | 0:f6c1b087dd68 | 22 | wait(0.2); |
cstevens | 0:f6c1b087dd68 | 23 | } |
cstevens | 0:f6c1b087dd68 | 24 | |
cstevens | 0:f6c1b087dd68 | 25 | } |