Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...

In this article, we are going make a project using Arduino remote control communication. A remote which consist of a IR light will be use as a IR transmitter to send the IR signals. We will use the IR sensor as a infrared detector to detect the infrared signals and then turn ON or OFF the LED’s according to that.

IR Communication basics

IR communication is basically done by two components, an IR transmitter which is a IR light placed in the remotes and a IR receiver which is IR sensor placed at the receiving end like in T.V’s, cars or anything which has to be controlled by the remote.

IR radiations are all around us but we cannot see them. IR communication is the cheapest and easiest form of wireless communication.  An IR light which transmits the IR light is very similar to the visible light but the difference is that the IR light has a slightly longer wavelength and also it is undetectable to the human eye. The wavelength of this IR light is between 930 to 950 nm. When a single button is pressed on the TV remote the IR LED blinks 38,000 times a second to transmit information to the IR sensor.


Whenever you press a button on the remote, the IR LED blinks thousands of time for the fraction of a second and sends the data to the IR receiver in encoded form. Each button has different code.

IR transmitter signal

The receiver then receives this signal and converts it into binary form to be read by the micro controller. The output of the IR receiver looks like this

IR sensor output

This output is then given to the micro-controller like Arduino by connecting the output of the IR receiver to the Arduino digital pin which is then used to control the devices like motors, LED’s or you can even make a home automation project with it.

Below is the gif taken from the explaining the working of the IR receiver and transmitter.

IR receiver and IR transmitter working

Components Required

The components required for Arduino remote control project are as follows

  • 1838B infrared IR sensor
  • Remote (Any remote can be used, most of the remotes work with it)
  • Arduino Uno
  • 4 X LED’s
  • 4 X 220 ohm resistors
  • Bread board
  • Connecting wires

Circuit Diagram and Explanation

The receiver I have used is 1838B IR sensor. The pin out of this model is given below. You can read more about it from the datasheet.  The receivers of other models are also available. You can use any other model but make sure to check out the pin out of that receiver because different IR sensors have different pin outs.

1828B IR sensor

1838B IR sensor

Connect the VCC of the IR sensor to the 5V of Arduino and GND of the IR sensor to the ground of Arduino. Then connect the OUT pin of IR sensor to the pin 2 of Arduino. After that, connect the LED’s at pin 12, 11, 10, 9 of Arduino through the 220 ohm resistor.

Arduino remote control communication


If you haven’t downloaded the library yet, download it from here before uploading the code.

#include <IRremote.h>   //including the remote library
#define button_1  25979 // code received from first button
#define button_2  15547 // code received from second button 
#define button_3  59295 // code received from third button
#define button_4  65015 // code received from fourth button 
int receiver_pin = 2;   //Connect the output pin of IR receiver here
//initializing the pins for leds
int first_led = 4;
int second_led = 5;
int third_led = 6;
int fourth_led = 7;
int led_state[] = {0,0,0,0,0}; //The initial state of the led's will be high
IRrecv receiver(receiver_pin); //Arduino will take output of IR receiver from pin 2
decode_results output;
void setup()
  receiver.enableIRIn();  // Start to take the output from IR receiver
  //initializing all the pins where we have connected the led's as output pins
  pinMode(first_led, OUTPUT);
  pinMode(second_led, OUTPUT);
  pinMode(third_led, OUTPUT);
  pinMode(fourth_led, OUTPUT);
void loop() {
  if (receiver.decode(&output)) {
    unsigned int value = output.value;
    switch(value) {
       case button_1:
         if(led_state[1] == 1) {        // checking whether the previous state is on or not
            digitalWrite(first_led, LOW);   //turn the first LED off
            led_state[1] = 0;           // set the state as low
         } else {                      // if first LED is off
             digitalWrite(first_led, HIGH); // uen it ON
             led_state[1] = 1;          // set the state to high
       case button_2:
         if(led_state[2] == 1) {
            digitalWrite(second_led, LOW);
            led_state[2] = 0;
         } else {
             digitalWrite(second_led, HIGH);
             led_state[2] = 1;
       case button_3:
         if(led_state[3] == 1) {
            digitalWrite(third_led, LOW);
            led_state[3] = 0;
         } else {
             digitalWrite(third_led, HIGH);
             led_state[3] = 1;
          case button_4:
         if(led_state[4] == 1) {       
            digitalWrite(fourth_led, LOW);
            led_state[4] = 0;           
         } else {                      
             digitalWrite(fourth_led, HIGH); 
             led_state[4] = 1;          

Code Explanation

In the code, we have defined four buttons from which we will control the led’s. Every button has different codes, so first we checked the code of each button and then defined in the Arduino IDE. The initial state of these buttons will be low means that when we will run the code, then all the LED’s will be low. We can change the initial state by changing the 0’s to 1’s in the line 13.

Line 20 will then take the output from the IR receiver. This output will tell us which button is pressed from the remote and will match the code of this button with the codes we have defined. If the code will match then it will on or off the LED connected to that pin.

How to run it

To run the code, first of all you need to download the library. Download the library from here and place it into the library folder.

It may conflict with the library that the late versions of Arduino IDE had when they are installed. So, remove the library from the installed Arduino IDE directory/libraries/RobotIRremote.

After installing the library, run the code and press the button from your remote. Open the serial monitor and it will show you the codes for the button you pressed.

Add this code in the Arduino IDE at the following places and now whenever you will press the button, the LED connected to that button will glow up.


If you have any questions, feel free to ask us in the comment section.

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
We hate spam. Your email address will not be sold or shared with anyone else.

Leave a Reply

Your email address will not be published.

Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...
Skip to toolbar