One fun way to control an Arduino is with a TV remote. In this project, I am going to show you how you can use any of the buttons on a standard infrared remote control to activate functions on an Arduino.
38 kHz Infrared Receiver Module
100 kohm Resistor
2 x 100 ohm resistor
Relay (5V 20 mA )
Breadboard or Printed Circuit Board
This project uses a multi-protocol infrared remote library that was developed by Ken Shirriff. This library allows the Arduino to both decode and transmit the infrared signals that are used in most commercial remote control systems.
You can download a copy of the IRRemote Library by going to his GitHub page and clicking the “Download ZIP” button on the right side of the page.
Next extract all the files. Move the "IRRemote" folder that has been extracted to your Arduino libraries directory. In the most recent versions of the Arduino software, there is another folder already in the library directory called “RobotIRremote.” This has a subfolder in it that is also named “IRRemote.” If both folders are in the library, the Arduino won’t know which one to reference and it will generate an error. The easiest way to resolve this problem is to simply delete the RobotIRremote folder. If you don’t want to delete it, you can go into the subfolders and rename all the folders that cause conflicts.
The infrared receiver module has three pins. As illustrated in the picture below, the right pin connects to 5V. The center pin connects to GND. The left pin is the output pin and connects to one of the digital pin on the Aduino set to input mode. This pin configuration may be different depending on the manufacturer of your part. So always consult the manufacturers datasheet before hooking it up. This in the only part that you need in order to receiver infrared signals with your Arduino. Once you have made these connections, you are ready to set up code.
Using this code, the Arduino will constantly monitor the output of the IR receiver module. When it detects a signal from a remote, it decodes the signal and converts it into a numerical value. This value is stored in a variable and can be used to activate any functions that you wish to add into the code. Using the Serial Monitor tool, you can see the number values that are generated by each button on your remote. Once you know the values, all you have to do is add them into your code and set up conditional statements that will perform the desired action whenever this button is pressed on the remote. When writing the code, keep in mind that a lot of remotes will send the same code multiple times or a series of codes every time you press a button.