Arduino Project: How to use TV Remote Control to Control Arduino

Recently, a lot of smart home applications are going on, people prefer to move from traditional way of controlling stuff into more automatic way.
For example, TVs and Air conditioners till today are being used with a dedicated remote controller. In our tutorial today - we are going to change it!We gonna teach you how to use Arduino Crowtail LED in order to capture the existing code from your TV remote and send it programatically using a push of a button!

What is IR?

Before we start with the tutorial, let’s try to understand what is IR and how exactly it works.

IR sensor is a simple electronic device which emits and detects IR radiation in order to find out certain objects/obstacles in its range. Some of its features are heat and motion sensing, in our example we are using IR emitter in order to transmit “codes” and receiver to “get” those codes and start a specific operation. In our case, TV remotes, the emitter is the TV remote which sends a command such as Turn ON/OFF or VOLUME UP/DOWN and the TV which is the receiver takes the code and covert it back into command.

IR sensors use infrared radiation of wavelength between 0.75 to 1000µm which falls between visible and microwave regions of electromagnetic spectrum. IR region is not visible to human eyes. Infrared spectrum is categorized into three regions based on its wavelength i.e. Near Infrared, Mid Infrared, Far Infrared.

If you take your phone camera for example and point it to your TV remote or to our Arduino IR emitter you’ll be able to see it flicking while sending the codes, what our eye cannot see - the camera is able to catch!

What is it useful for?

You can create multiple applications and connect it to additional sensors, for example on motion detection turn on or turn off the TV, Detect clapping and turn on and off the TV and much much more!

Unlike TV remotes, Air conditioner remotes are a bit more complex than that. TV remote send repeating code all the time but Air conditioner remote send different codes based on the remote state. the AC remote have multiple configurations including: Temperature, Motor power, On/Off, Fan speed etc ….
In this tutorial we’ll only focus on TV remotes. as explained before, IR can be used for many other applications as well such as: distance and motion detection.

For this tutorial we’ll need a couple of hardware:

Arduino Uno
Crowtail base shield - https://www.elecrow.com/crowtail-base-shield-p-1264.html
Crowtail IR emitter - https://www.elecrow.com/crowtail-ir-emitter-p-1308.html
Crowtail IR Receiver - https://www.elecrow.com/crowtail-ir-receiver-p-1307.html
Crowtail Button - https://www.elecrow.com/crowtail-button-pack.html


Crowtail IR Receiver - https://www.elecrow.com/crowtail-ir-receiver-p-1307.html
Crowtail Button - https://www.elecrow.com/crowtail-button-pack.html

Software you might need:
Arduino IDE - www.arduino.cc

Next, after we got all the required hardware, it’s time to install some libraries.We’ll use a library called “IRremote” which can be downloaded from the official github:https://github.com/z3t0/Arduino-IRremoteDownload the library and copy it into your libraries folder of the Arduino IDE.

We’ll need to connect the hardware in the following way:

Button - PIN D12
IR Emitter - PIN D4
IR Receiver - PIN D11

The pin names and numbers written on top of the Crow-tail shield, just plug it in to the right place!

Then we’ll need our code:

We can get our code from the IRremote library examples by opening the Arduino IDE, Going to File -> Examples -> IRremote -> IRrecord.

You should see something like this:

After you have the code, connect the Arduino by USB and press the “Upload” button in order to upload the code into your Arduino.

Once it’s uploaded, open the serial communication in order to see the information, the logic of the code works in the following way.

If you want to record a new code from your TV remote, maker sure to bring the TV remote close enough to the Crowtail IR Receiver and press any button you want to record on the TV remote. It should immediately show you the remote codes saying “saving as row” which means it’s been saved into the Arduino memory. 

the next thing would be to press the Crowtail button when you want to submit the code to the TV (repeat it) for example, if you saved the on/off button repeating it will either turn on or turn off the TV! if it doesn’t work for you, make sure the LED is close enough to the TV and looking into it’s direction.


If you’d like to learn more examples and more ways to record and transmit codes, there are plenty more of built in programs in the IRremote library that you can work and experiment with! today we covered the most important one and we really can’t wait to see what you going to do with it!