Friday, February 27, 2015

Arduino LG TV IR Remote Control Decoder

LG Television infrared remote control protocol decoder using Arduino

Control you Arduino from RC5 remote control and LGTV remote control

There is a remote control for some LG televisions uses a protocol like the Philips RC5 protocol, the only difference between the tow is bit length. The RC5 has a bit length of 1.778ms while this LG remote has a bit length probably of 1.667ms.
The following link is an application of decoding the RC5 protocol using Arduino:

Now using the same circuit of the previous topic we are going to modify the previous code to work with the LG television remote control.

arduino lgtv lg ir remote control decoder arduino code
 
 LG television remote control decoder Arduino code:

#include <LiquidCrystal.h>
 LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
 unsigned char j, m, toggle, address, command=0;
 void setup() {
 lcd.begin(16, 2);
 pinMode(2, INPUT);
 }
 void loop() {
 lcd.clear();
 lcd.setCursor(2, 0); lcd.print("Arduino LGTV");
 lcd.setCursor(3, 1); lcd.print("IR decoder");
 delay(1000);
 lcd.clear();
 lcd.setCursor(2, 0); lcd.print("Toggle bit:");
 lcd.setCursor(1, 1); lcd.print("Addr:   Cmd:");
 while(1){
  return_:
  while(digitalRead(2));
  //Check if the received signal is RC5 protocol
  for(m = 0; m < 24; m++){
    delayMicroseconds(100);
    if(digitalRead(2) != bitRead((m >> 3),0))
    goto return_;}
   //End checking 
 delayMicroseconds(1300);
 //Read data
 for(j = 0; j < 12; j++){
 if (j == 0){
   if(digitalRead(2) == LOW) toggle = 1;
   else toggle = 0;}
 else {
 if (j < 6){
  if(digitalRead(2) == LOW){ bitSet(address, 5 - j);}
  else bitClear(address,5 - j);}
  else{
  if(digitalRead(2) == LOW){ bitSet(command, 11 - j);}
  else bitClear(command, 11 - j);}}
 delayMicroseconds(1660);        }
 //End read data
 //Display results
 lcd.setCursor(13, 0); lcd.print(toggle);
 lcd.setCursor(6, 1); lcd.print(address / 10);
 lcd.setCursor(7, 1); lcd.print(address % 10);
 lcd.setCursor(13, 1); lcd.print(command / 10);
 lcd.setCursor(14, 1); lcd.print(command % 10);
 }  
 }