CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to

Lite-On Airboard IR Keyboard decoder

Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message

Joined: 27 Jan 2006
Posts: 69
Location: Manchester, England

View user's profile Send private message

Lite-On Airboard IR Keyboard decoder
PostPosted: Thu Nov 30, 2006 8:58 pm     Reply with quote

I was given a Lite-On Airboard Wireless Keyboard (IR). but it had no receiver.

I built a pic small circuit (PIC18F252,10MHz XTAL,RS232) and I put an IR module which i removed from a DVD player on to pin C0 of my PIC.
after lots of fiddling I have come up with this peice of code that works.

I got the numbers 1-0 all to display on the LCD and the raw codes get sent to the RS232 for me to get the key code.

#use rs232(baud=1200,xmit=pin_c1,rcv=pin_c0,stream=ir)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=tty)

   if (0xff!=a)
     b=fgetc(ir); c=fgetc(ir); d=fgetc(ir);
     e=fgetc(ir); f=fgetc(ir);
       case 0xd1 :
       case 0xd0 :

// this continues for all the number keys
// removed for forum posting


I want to do the entire keyboard and eventually move it to a PIC18F4550 and turn it into a USB keyboard interface.

So far I only did 10 keys and the C is getting to be very long. I'm still new to C programming so this is the best way I can reference which key makes which character on the screen.

If anyone has any more efficient way of doing this then I would be glad to hear it.

Joined: 27 Jan 2006
Posts: 69
Location: Manchester, England

View user's profile Send private message

PostPosted: Thu Nov 30, 2006 9:18 pm     Reply with quote

If you are wondering, the LCD is a 20x4 LCD with backlight.
the driver I used for the LCD is in this thread ->

Joined: 27 Jan 2006
Posts: 69
Location: Manchester, England

View user's profile Send private message

PostPosted: Wed Dec 06, 2006 11:21 pm     Reply with quote


I've now mapped all alpha-numeric keys, Space, Enter, Home and Caps lock. Ive also optimised it to notice the end of a packet. 0xA5 appears to be the end byte.


    while(0xa5!=b) // loop till end marker.

       case 0xd1 : {if (0==capslock) printf(lcd_putc,"1");else printf(lcd_putc,"!");break;}
       case 0xd0 : {if (0==capslock) printf(lcd_putc,"2");else printf(lcd_putc,"@");break;}
       case 0xd7 : {if (0==capslock) printf(lcd_putc,"3");else printf(lcd_putc,"#");break;}
       case 0xd6 : {if (0==capslock) printf(lcd_putc,"4");else printf(lcd_putc,"$");break;}
       case 0xd5 : {if (0==capslock) printf(lcd_putc,"5");else printf(lcd_putc,"%%");break;}
       case 0xd4 : {if (0==capslock) printf(lcd_putc,"6");else printf(lcd_putc,"^");break;}
       case 0xdb : {if (0==capslock) printf(lcd_putc,"7");else printf(lcd_putc,"&");break;}
       case 0xda : {if (0==capslock) printf(lcd_putc,"8");else printf(lcd_putc,"*");break;}
       case 0xd9 : {if (0==capslock) printf(lcd_putc,"9");else printf(lcd_putc,"(");break;}
       case 0xd8 : {if (0==capslock) printf(lcd_putc,"0");else printf(lcd_putc,")");break;}
       case 0xf8 : {printf(lcd_putc,"\n");break;} //enter
       case 0x83 : {lcd_gotoxy(0,0); break;} //home
       case 0xc2 : {if (1==capslock) printf(lcd_putc,"Q");else printf(lcd_putc,"q");break;}
       case 0xc1 : {if (1==capslock) printf(lcd_putc,"W");else printf(lcd_putc,"w");break;}
       case 0xc0 : {if (1==capslock) printf(lcd_putc,"E");else printf(lcd_putc,"e");break;}
       case 0xc7 : {if (1==capslock) printf(lcd_putc,"R");else printf(lcd_putc,"r");break;}
       case 0xc6 : {if (1==capslock) printf(lcd_putc,"T");else printf(lcd_putc,"t");break;}
       case 0xc5 : {if (1==capslock) printf(lcd_putc,"Y");else printf(lcd_putc,"y");break;}
       case 0xc4 : {if (1==capslock) printf(lcd_putc,"U");else printf(lcd_putc,"u");break;}
       case 0xcb : {if (1==capslock) printf(lcd_putc,"I");else printf(lcd_putc,"i");break;}
       case 0xca : {if (1==capslock) printf(lcd_putc,"O");else printf(lcd_putc,"o");break;}
       case 0xc9 : {if (1==capslock) printf(lcd_putc,"P");else printf(lcd_putc,"p");break;}
       case 0xcc : {if (1==capslock) printf(lcd_putc,"A");else printf(lcd_putc,"a");break;}
       case 0xf3 : {if (1==capslock) printf(lcd_putc,"S");else printf(lcd_putc,"s");break;}
       case 0xf2 : {if (1==capslock) printf(lcd_putc,"D");else printf(lcd_putc,"d");break;}
       case 0xf1 : {if (1==capslock) printf(lcd_putc,"F");else printf(lcd_putc,"f");break;}
       case 0xf0 : {if (1==capslock) printf(lcd_putc,"G");else printf(lcd_putc,"g");break;}
       case 0xf7 : {if (1==capslock) printf(lcd_putc,"H");else printf(lcd_putc,"h");break;}
       case 0xf6 : {if (1==capslock) printf(lcd_putc,"J");else printf(lcd_putc,"j");break;}
       case 0xf5 : {if (1==capslock) printf(lcd_putc,"K");else printf(lcd_putc,"k");break;}
       case 0xf4 : {if (1==capslock) printf(lcd_putc,"L");else printf(lcd_putc,"l");break;}
       case 0xfd : {if (1==capslock) printf(lcd_putc,"Z");else printf(lcd_putc,"z");break;}
       case 0xfc : {if (1==capslock) printf(lcd_putc,"X");else printf(lcd_putc,"x");break;}
       case 0xe3 : {if (1==capslock) printf(lcd_putc,"C");else printf(lcd_putc,"c");break;}
       case 0xe2 : {if (1==capslock) printf(lcd_putc,"V");else printf(lcd_putc,"v");break;}
       case 0xe1 : {if (1==capslock) printf(lcd_putc,"B");else printf(lcd_putc,"b");break;}
       case 0xe0 : {if (1==capslock) printf(lcd_putc,"N");else printf(lcd_putc,"n");break;}
       case 0xe7 : {if (1==capslock) printf(lcd_putc,"M");else printf(lcd_putc,"m");break;}
       case 0xee : {printf(lcd_putc," "); break;} //space
       case 0xe6 : {if (0==capslock) printf(lcd_putc,",");else printf(lcd_putc,"<");break;}
       case 0xe5 : {if (0==capslock) printf(lcd_putc,".");else printf(lcd_putc,">");break;}
       case 0xc3 : {printf(lcd_putc,"    "); break;} //tab (im using 4 space)
       case 0xc8 : {if (0==capslock) printf(lcd_putc,"[");else printf(lcd_putc,"{");break;}
       case 0xcf : {if (0==capslock) printf(lcd_putc,"]");else printf(lcd_putc,"}");break;}
       case 0xec : {printf(lcd_putc,"\f "); lcd_gotoxy(0,0); break;} //display (special key) (im using it to clear LCD)

       case 0xcd : {if (1==capslock) capslock=0;
                    else capslock=1;
                    break;} //caps lock

The caps lock part actually acts like a shift lock. it gives uppercase letter when its on and the symbol above the numbers also.

The keys I noticed give a press code (which repeats every second if held) then a release code. Im going to map the press code for the shift to set a variable then to unset it upon receiving the release key (or possible the absence of a press signal after a period incase the ir misses the release signal).

I'm also working on get the USB keyboard and mouse demo to be built using a PIC18F4550 so I can use it as a basis to move this project to and have a wireless keyboard/mouse.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group