IR receiver for TG-LPC11U35-501

Dependencies:   AQM0802 IR mbed

Files at this revision

API Documentation at this revision

Comitter:
yasuyuki
Date:
Sat Sep 26 13:15:46 2015 +0000
Parent:
2:31c91b18bba9
Child:
4:4642c669045c
Commit message:
revised

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 25 17:13:57 2015 +0000
+++ b/main.cpp	Sat Sep 26 13:15:46 2015 +0000
@@ -1,5 +1,5 @@
 //**********************
-// Infrared Rays receiver sample for mbed
+// Infrared Rays receiver and transceiver sample for mbed
 //
 // LPC1768 flash=512KB, ADC=12bits
 // LPC11U35 flash=64KB, ADC=10bits
@@ -59,7 +59,8 @@
 int main() {
     
     char msg[10];
-    char i;
+    char i,n;
+    char name[][5]={"none","NEC ","AEHA","SONY"};
     
     button.fall(&irInterrupt);
     button.mode(PullUp);
@@ -72,24 +73,19 @@
     while(1) {
 
         lcd.locate(0,0);
-        sprintf(msg,"%02X",ir.bits);    // bits
+        sprintf(msg,"%s",name[ir.mode]);    // 1:NEC, 2:AEHA, 3:SONY
         lcd.print(msg);
-        sprintf(msg,"%02X",ir.mode);    // 1:NEC, 2:AEHA, 3:SONY
+        sprintf(msg,"%4d",ir.bits);    // bits
         lcd.print(msg);
 
-        for(i=0;i<2;i++){
-//        for(i=5;i<7;i++){
-            sprintf(msg,"%02X",ir.buf[i]);  // data
-            lcd.print(msg);    
+        // scroll
+        n=(ir.bits+7)/8;    // bits to n bytes
+        for(i=0;i<n;i++){
+            lcd.locate(0,1);
+            sprintf(msg,"buf%02d=%02X",i,ir.buf[i]);  // data
+            lcd.print(msg);
+            wait(1);
         }
-
-        lcd.locate(0,1);
-        for(i=2;i<6;i++){
-//        for(i=11;i<15;i++){
-            sprintf(msg,"%02X",ir.buf[i]);  // data
-            lcd.print(msg);    
-        }
-        wait(1);
         
 
         // Echo back
@@ -100,9 +96,11 @@
         // ir.buf[] are bytes buffer
         ir.setIR();
         button.fall(&irInterrupt);  // enable Interrupt
+        lcd.locate(0,1);
+        sprintf(msg,"sent out");
+        lcd.print(msg);
         wait(1);
         
-        
     }
 
 }