Beginner’s Guide to Use an IR Remote Transmitter and Receiver With Arduino

by Electropeak in Circuits > Arduino

6775 Views, 7 Favorites, 0 Comments

Beginner’s Guide to Use an IR Remote Transmitter and Receiver With Arduino

Figure1 IR-Remote-Sender-Receiver - Copy.jpg

Overview

In this tutorial, you’ll learn about IR protocol and how to use the IR receiver Module. First, you’ll see how the IR protocol works, and then you will learn to use an IR remote control kit with Arduino. Some practical examples are also provided to help you learn it better.

What You Will Learn

  • What IR is and how it works
  • Introduction of IR Receiver Modules
  • How to use an IR module with Arduino
  • Controlling keyboard with IR remote control

Introduction to IR Protocol

Figure-2-IR-Receiver-Modules.jpg
Figure-3-IR-Receiver-Modules-pinout.png

IR or infrared communication is one of the most common methods of wireless communication due to being easy to use and having an affordable price. Infrared light, with a wavelength longer than visible light, is not within the range of human vision. That’s why it’s a good option for wireless communications. When you press a button on your TV control, an LED on your control turns on and off continuously and causes a modulated infrared signal to send from the control to your TV. The command will execute after the signal is demodulated. IR receiver modules are used to receive IR signals. These modules work in 3,8 KHz frequency. When the sensor is not exposed to any light at its working frequency, the Vout output has a value equal to VS (power supply). With exposing to a 38 kHz infrared light, this output will be zero.

These modules have 3 pins for VOUT, VDD, and Ground so it’s very easy to use them in circuits.

Required Materials

Find the Code for Each Remote Control Button

In this part, we want to set up a connection between the Arduino and an IR sender and receiver. To do this, we first need to know the code for each button on the remote control. By pressing eachbutton, a specific signal sends to the receiver and will be displayed on the Serial Monitor window.

Circuit

Figure-4-circuit1-1.png

Code

You need to install the IR library to use an IR module. Download the library from the following link and in the Sketch window, open the Include library option and select IRRemote.h.

This library may be available in your Arduino libraries by default. In this case, you don’t need to install it.

Let’s take a closer look to the code:

<p>int RECV_PIN = 7; </p><p>IRrecv irrecv(RECV_PIN);</p>

Specifying the pin that is connected to receiver module output.

irrecv.enableIRIn();

initilization to receive IR signals

<p>if (irrecv.decode(&results))</p>

irrecv.decode(&results) function decodes the received IR signal and store it in variable result. It returns 0 when nothing is received.

Downloads

Controlling an RGB LED Colors Using the IR Remote Control

After you found the code for each button, you can use it to control the commands. In this example, we connected an RGB LED to Arduino and use the remote control to change the colors. To do this, specify a few buttons on the remote control and save their code. In this example, buttons 1 to 3 are used. Then assign a specific color to each button. At the end by pressing any of the 1 to 3 keys, the LED changes its color.

For more colors, you can find the code for each color here.

Circuit

Figure-5-circuit2-1.png

Code

rgb.gif

Downloads

Use the IR Remote Control to Play Super Mario!

Now you are going to play super Mario using the IR remote instead of your keyboard. To do this you need an Arduino Leonardo (or Micro) board.

Circuit

Figure-6-circuit3-1.png

Code

mario-test.gif

In order to control the keyboard, you need the keyboard.h library. You can find it in the following link:

Keyboard.h Library

Note

NoteKeyboard.h library allows only the 32u4 and SAMD based boards (Leonardo, Esplora, Zero, Due and MKR Family) to acts as a keyboard.

Downloads

What’s Next?

Figure1 IR-Remote-Sender-Receiver.jpg
  • Try to control a robot using IR remote control

Like our FaceBook page to notice the latest projects and also support our team:

www.facebook.com/electropeak