Remote Control Using Arduino

Introduction

 
In my previous article, I explained how we can control led using a button. In this article, I'll show you how can we use remote control using Arduino UNO.
 
Requirements
  • Arduino
  • IR sensor
  • Bread Board
  • IR Remote
  • Led
  • Jumper wires
Connection
 
Step 1: Connect the Arduino board to the pc using the USB cable.
 
Step 2:  Fix the led and IR sensor on the breadboard.
 
Step 3:  IR sensor connection.
 
 
Figure 1: IR Sensor 
 
Step 4: Connect the IR Sensor to the Arduino board Vin -3pin, Gnd - Gnd and Vcc - 5v.
 
Step 5: Connect the led to the Arduino board Anode pin - 13pin and Cathode pin to the Gnd.
 
Programming
  1. # include < IR.Remote.h >   
  2. int RECV_PIN = 3;    
  3. Iint led = 13;    
  4. int its ONled[] = {2};    
  5. int ledstates[] = {0,0};  
  6. # define code1 22695    
  7. IRrec irrecv(RECV PIN);    
  8. decode_results.results;    
  9. void setup()    
  10. {    
  11.     serial.begin(9600);    
  12.     irrecv.enableIRIn();    
  13.     pinMode(led, OUTPUT);    
  14. }    
  15. void loop()    
  16. {    
  17.     if (irrecv.decode(results))    
  18.     {    
  19.         unsigned int value = results.value;    
  20.         switch (value)    
  21.         {    
  22.         case code1:    
  23.             if (itsONled[1] == 1)    
  24.             {    
  25.                 digitalWrite(led, LOW);    
  26.                 itsONled[1] = 0;    
  27.             }    
  28.             else    
  29.             {    
  30.                 digitalWrite(led, HIGH);    
  31.                 itsONled[1] = 1;    
  32.             }    
  33.             break;    
  34.         }    
  35.         serial.println(value);    
  36.         Irrec resume();    
  37.     }    
  38. }   
     
IR REMOTE FUNCTION:   
 
 
Figure 2: IR Remote
 
Step 1:
To use the IR REMOTE we have to download the IR LIBRARY
 
Step 2:
Click to download the library - IR Arduino library
 
Step 3: Add the library to the Arduino software library.
 
Explanation
 
Press any button and see the code value in the serial monitor, copy the code, and sketch the code in the program. We can add many LEDs in the connection. If we press the first button the led can be ON. Then on pressing another button, the first led is ON and second led TURN ON. We can add other LEDs and it can be changed in the switch() function. We can control the TV, AC by using the remote.

Recommended Ebook

Printing in C# Made Easy

Download Now!
Similar Articles