Introduction: Controlling a TV and Connected Raspberry Pi With the Same Remote

To control a Raspberry Pi with Infrared remote, we used to be able to use LIRC. That used to work up until Kernel 4.19.X when it became a lot more challenging to get LIRC to work. In this project we have a Raspberry Pi 3 B+ connected to a TV and we need to get rid of the keyboard and mouse. We will no longer need to install LIRC on RPi or any device we use this project with which will free up resources.


  • Arduino Pro Micro
  • IR sensor
  • Micro USB cable

Step 1: Solder IR Sensor on Arduino Pro Micro

TSOP1836 IR sensor has three pins: Signal, GND, and Vcc. Make sure you lookup pinout for your sensor before soldering. Next, Solder sensor's GND to board's GND, sensors's Vcc to board's, and sensor's Signal to pin 2 of Arduino Pro Micro. Don't forget to wrap the board to protect it, but leave the sensor exposed.

Step 2: Upload Code to Arduino Pro Micro

Code can be found in Github.

Step 3: Getting Your Remote's Codes

There is a very small chance that your code will work now and you'll be done with this project. For the vast majority of maker who are not using the same remote as mine, you will need to read your remote's codes. Open Arduino IDE Serial Monitor and make sure the Baud Rate matches what we have in the code in line "Serial.begin(115200);". Point your remote at IR sensor then press one button and release quickly to get at least two lines in Serial Monitor. The first line is the code for the button and the following line is the remote's way of saying just repeat the last code.

Step 4: Update Your Arduino Pro Micro Sketch and Upload Again

You will notice two kinds of remote codes in the sketch you downloaded from Github:

  • Repeatable: used for mouse movement (hold down the button to keep mouse moving)
  • Non-repeatable: used for single button press such as left mouse button click

In addition to the code you obtained from the previous step, you need to update the size of "const int ButtonCount" which is 32 in my sketch because I have 32 button codes defined in ResultsValues[ButtonCount].

Last but not least, you need to update the following line:

if (Results.value == 4294967295) for (int i = 0; i < ButtonCount; i++) AllButtons[i] = RepeatCode[i];

Replace 4294967295 with the repeat code of your remote. That code can be obtained from the previous step by holding down any remote button. The repeating code will be the code showing up multiple times.

First Time Author Contest

Participated in the
First Time Author Contest