Interfacing Infrared to Arduino Uno

Introduction

I am thinking if it is possible to create a single remote controller for the appliances in our home. So I do some search in google on how to interface infrared to a microcontroller. To my surprised it was very easy. But for the meantime while I do not have the materials, here is the infrared decoder. This could decode infrared code sent by our remote controllers, and ofcourse every remote controller has a different set of code. With the power of microcontroller, it is possible to change the set of IR code by just pressing a single button switch. LEDs will be use as indicators. Hello peeps. I am George, welcome to tech-to-tinker channel, where technology is explored and shared.

And today, I am going to show you my tinkering with the Infrared reciever to Arduino Uno

Bill Of Materials

  1. Arduino Uno
  2. Keypad/LCD shield
  3. Infrared receiver
  4. Some jumper wires

Hardware Instruction

  1. Connect the Keypad/LCD shield at the top of Arduino Uno board. Only the LCD of the shield will be use for this tinkering.
  2. Connect the Infrared receiver as follows from Right-to-Left:
    • VCC connected to Arduino 5V (red wire)
    • GND connected to Arduino GND (black wire)
    • Output pin connected to digital pin 3 of Arduino (white wire)
  3. Upload the sketch provided.
  4. Enjoy.

Video Demonstration

Source Code

  1
  2#include "IRremote.h"
  3#include "LiquidCrystal.h"
  4
  5LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  6
  7const int RECV_PIN = 3;
  8IRrecv irrecv(RECV_PIN);
  9decode_results results;
 10unsigned long key_value = 0;
 11
 12void setup(){
 13  Serial.begin(9600);
 14  irrecv.enableIRIn();
 15  irrecv.blink13(true);
 16
 17  // LCD
 18  lcd.begin(16, 2);
 19  lcd.setCursor(0, 0);
 20  lcd.print(" tech-to-tinker ");
 21  lcd.setCursor(0, 1);
 22  lcd.print(" IR Code:");
 23}
 24
 25void loop(){
 26  if (irrecv.decode(&results)){
 27        if (results.value == 0XFFFFFFFF)
 28          results.value = key_value;
 29        
 30        switch(results.value){
 31        /*
 32          case 0xFDD22D:
 33            Serial.println("CH-");
 34            lcd.setCursor(10, 1); // set the position
 35            lcd.print("      ");
 36            lcd.setCursor(10,1);
 37            lcd.print("CH-");
 38            break;
 39          case 0xFD52AD:
 40            Serial.println("CH+");
 41            lcd.setCursor(10, 1); // set the position
 42            lcd.print("      ");
 43            lcd.setCursor(10,1);
 44            lcd.print("CH+");
 45            break;
 46          case 0xFD6A95:
 47            Serial.println("<<");
 48            lcd.setCursor(10, 1); // set the position
 49            lcd.print("      ");
 50            lcd.setCursor(10,1);
 51            lcd.print("<<");
 52            break;
 53          case 0xFDEA15:
 54            Serial.println(">>");
 55            lcd.setCursor(10, 1); // set the position
 56            lcd.print("      ");
 57            lcd.setCursor(10,1);
 58            lcd.print(">>");
 59            break ;  
 60          case 0xFD8A75:
 61            Serial.println(">||");
 62            lcd.setCursor(10, 1); // set the position
 63            lcd.print("      ");
 64            lcd.setCursor(10,1);
 65            lcd.print(">||");
 66            break ;               
 67          case 0xFD926D:
 68            Serial.println("Vol-");
 69            lcd.setCursor(10, 1); // set the position
 70            lcd.print("      ");
 71            lcd.setCursor(10,1);
 72            lcd.print("Vol-");
 73            break ;  
 74          case 0xFD12ED:
 75            Serial.println("Vol+");
 76            lcd.setCursor(10, 1); // set the position
 77            lcd.print("      ");
 78            lcd.setCursor(10,1);
 79            lcd.print("Vol+");
 80            break ;  
 81          case 0XFDC837:
 82            Serial.println("UP");
 83            lcd.setCursor(10, 1); // set the position
 84            lcd.print("      ");
 85            lcd.setCursor(10,1);
 86            lcd.print("UP");
 87            break ;  
 88          case 0xFD8877:
 89            Serial.println("LEFT");
 90            lcd.setCursor(10, 1); // set the position
 91            lcd.print("      ");
 92            lcd.setCursor(10,1);
 93            lcd.print("LEFT");
 94            break ;  
 95          case 0xFD28D7:
 96            Serial.println("DOWN");
 97            lcd.setCursor(10, 1); // set the position
 98            lcd.print("      ");
 99            lcd.setCursor(10,1);
100            lcd.print("DOWN");
101            break ;
102          case 0XFD48B7:
103            Serial.println("RIGHT");
104            lcd.setCursor(10, 1); // set the position
105            lcd.print("      ");
106            lcd.setCursor(10,1);
107            lcd.print("RIGHT");
108            break ;
109          case 0xFD08F7:
110            Serial.println("ENTER");
111            lcd.setCursor(10, 1); // set the position
112            lcd.print("      ");
113            lcd.setCursor(10,1);
114            lcd.print("ENTER");
115            break ;
116          case 0xFDAA55:
117            Serial.println(">>|");
118            lcd.setCursor(10, 1); // set the position
119            lcd.print("      ");
120            lcd.setCursor(10,1);
121            lcd.print(">>|");
122            break ;
123          case 0xFD2AD5:
124            Serial.println("|<<");
125            lcd.setCursor(10, 1); // set the position
126            lcd.print("      ");
127            lcd.setCursor(10,1);
128            lcd.print("|<<");
129            break ;
130          case 0xFD4AB5:
131            Serial.println("STOP");
132            lcd.setCursor(10, 1); // set the position
133            lcd.print("      ");
134            lcd.setCursor(10,1);
135            lcd.print("STOP");
136            break ;
137          */
138          default:
139            Serial.println(results.value,HEX);
140            lcd.setCursor(10, 1); // set the position
141            lcd.print("      ");
142            lcd.setCursor(10,1);
143            lcd.print(results.value,HEX);
144            break ;      
145        }
146        key_value = results.value;
147        irrecv.resume(); 
148        //delay(2000);
149  }
150}

Call To Action

If you find this blog post useful, please kindly support my blogs:
techtotinker.com TechToTinker Youtube Channel



Posts in this series



No comments yet!

GitHub-flavored Markdown & a sane subset of HTML is supported.