Electronics components, Hobby, Light, Microcontrollers, Projects, Sensors, Tutorial, Wireless

Arduino tutorial (Part 8, IR remote control)

One more Arduino tutorial. This time will be explained how to control devices with IR remote control. The operation of IR (infrared) control will be subject to other post.

Connections

First we must connect the receiver module to Arduino.

The pin next to the signal “-” is the ground, the pin in the middle is to 5V and the pin next to the “S” is to receive the IR signal. The signal pin must be linked to a digital input.

Here the receiver is linked to digital pin 7.

Adding new library

Before write the algorithm, it is necessary to download a library to facilitate the IR control, download the library in this link. Then save the zip file in a place easy to find, can be the own PC’s workplace. Open the Arduino program, do according to the video below and click in “Add library ZIP”.

Then, find the zip file and click twice. Will appear a warning below the Arduino program’s window that the library has been included.

Algorithm and new commands

Now let’s write the algorithm which will allow the IR remote control.

The serial screen must appear like showed below. When press any button of remote control, must appear a different code in hexadecimal.

Now let’s see the new commands. These below are declaration of instances “IRrecv” and “decode_results” respectively.

IRrecv irrecv(RECV_PIN);
decode_results results;

This command verify if IR signal has been received.

if(irrecv.decode(&results)){

Print the variable results in hexadecimal.

Serial.println(results.value,HEX);

Some projects

This project controls a RGB LED and a buzzer with IR remote control. Here shows the RGB LED and buzzer connected to Arduino.

The complete circuit. The IR receiver stays in the same pin of previous example.

This is the complete algorithm.

Pressing the buttons 1, 2 or 3, the LED lights up in one of primary colors. When press 4, 5 or 6 can lights up two or three colors, making combinations. Two buttons control the buzzer. The next project is a robotic arm with three servomotors controlled by IR. This is the assembled arm.

This is the algorithm.

 

This video shows the robotic arm in operation.

 

 

Liked it? Take a second to support Electrical e-Library on Patreon!

About Pedro Ney Stroski

Leave a Reply

Your email address will not be published. Required fields are marked *