使用红外接收库的一个demo code

Dependencies:   mbed

Fork of IR_remote by Armando Casalino

Revision:
0:42764550a2cb
Child:
1:5e7be7addf96
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 13 08:02:24 2017 +0000
@@ -0,0 +1,39 @@
+#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]);
+                    }
+                */
+                
+            }
+            
+        }
+
+    }
+}