chen ada
/
IR_remote_demo_code
使用红外接收库的一个demo code
Fork of IR_remote by
main.cpp
- Committer:
- havebug
- Date:
- 2017-07-13
- Revision:
- 0:42764550a2cb
- Child:
- 1:5e7be7addf96
File content as of revision 0:42764550a2cb:
#include "mbed.h" #include "ReceiverIR.h" ReceiverIR ir_rx(D2); Serial pc(SERIAL_TX, SERIAL_RX); DigitalOut myled(LED1); RemoteIR::Format format; uint8_t buf[32]; int bitcount; int main() { pc.printf("Hello World !\r\n"); while(1) { if (ir_rx.getState() == ReceiverIR::Received) { bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8); myled = !myled; if (bitcount>0){ pc.printf("Decoded: %02X \r\n", buf[3]); myled = !myled; /* DEBUG for (int i = 0; i < bitcount; i++) { pc.printf("%02X", buf[i]); } */ } } } }