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

Dependencies:   mbed

Fork of IR_remote by Armando Casalino

Revision:
4:326b8df3add2
Parent:
3:29915623fbb0
--- a/main.cpp	Fri Jul 14 09:59:40 2017 +0000
+++ b/main.cpp	Thu Jun 21 01:20:35 2018 +0000
@@ -3,11 +3,11 @@
 
 DigitalOut  my_led(LED1);
 
-PwmOut      my_pwm1(PB_3);
-PwmOut      my_pwm2(PB_5);
+//PwmOut      my_pwm1(PB_3);
+//PwmOut      my_pwm2(PB_5);
 
 
-ReceiverIR ir_rx(D2);
+ReceiverIR ir_rx(PA_12);
 
 Serial pc(SERIAL_TX, SERIAL_RX);
 DigitalOut myled(LED1);
@@ -19,11 +19,11 @@
 
 int main()
 {
-    my_pwm1.period_us(200);
-    my_pwm1.write(DC);
+    //my_pwm1.period_us(200);
+    //my_pwm1.write(DC);
     
-    my_pwm2.period_us(200);
-    my_pwm2.write(DC);
+    //my_pwm2.period_us(200);
+    //my_pwm2.write(DC);
        
 
     pc.printf("Hello World !\r\n");
@@ -34,26 +34,29 @@
             myled=1;
             if (bitcount>0) {
                 decoded=buf[3];
-                pc.printf("\r\nDecoded: %02X ", buf[3]);
+                pc.printf("\r\nDecoded: %x ", buf[0]);
+                pc.printf("\r\nDecoded: %x ", buf[1]);
+                pc.printf("\r\nDecoded: %x ", buf[2]);
+                pc.printf("\r\nDecoded: %x ", buf[3]);
             }
                 
                 pc.printf(".");
                 myled = !myled;
                     
-                if (decoded==0xE5){
-                    DC = DC+ 0.01;
-                    if (DC>1) DC=1;
-                }
-                if (decoded==0xD4){
-                    DC = DC- 0.01;
-                    if (DC<0) DC=0;
-                }    
-                if (decoded==0xC3){
-                    DC = 0.5;
-                }   
+                //if (decoded==0xE5){
+                //    DC = DC+ 0.01;
+                //    if (DC>1) DC=1;
+                //}
+                //if (decoded==0xD4){
+                //    DC = DC- 0.01;
+                //    if (DC<0) DC=0;
+                //}    
+                //if (decoded==0xC3){
+                //    DC = 0.5;
+                //}   
                     
-                    my_pwm1.write(DC);
-                    my_pwm2.write(DC);
+                //    my_pwm1.write(DC);
+                //    my_pwm2.write(DC);
                 
                 
                 /* DEBUG