• Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

*/ ?>

You are a beginner with Croduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by e-radionica where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Croduino and the basic code. Everything else is left to your imagination..


In this tutorial, you will learn how to manage different devices via IR connection. Besides the remote that is included in this package, you can use any other remote you have and program it the way you want to. Connecting the IR receiver to Croduino is simple, and the complete system works at a standard frequency of 38kHz for IR control. Characteristics: • Current: max. 5mA • Frequency: 38kHz • Dimensions: 115mm x 80mm x 15mm, 22g

How does it work?

In order to know how the module works, we first need to know what IR is. IR stands for infrared (infrared light beams), the light that is beyond the range of visible light, i.e. invisible to the eye. Since IR is a type of light, IR communication requires a direct line of visibility from the receiver to the transmitter. It can not pass through walls like WiFi or Bluetooth can. A typical infrared communication system requires an IR transmitter and an IR receiver. The remote transmitter looks like a standard LED, it only creates light in the IR spectrum instead of the visible spectrum. If you look at the front of the TV remote controller, you will see the LED of the remote controller: The IR receiver is a photodiode and a pre-amplifier that converts IR light into an electric signal. Diodes of the IR receivers usually look like this when connected to the board, but they can be used even without: The IR light is emitted by the sun, light and everything else that creates heat. This means there is a lot of IR light pollution around us. In order to prevent IR signal contamination, the signal modulation technique is used. With IR modulation, the encoder on the IR remote controller converts the binary signal into a modulated electrical signal. This electrical signal is sent to the LED transmitter. The LED transmitter converts the modulated electrical signal into a modulated IR signal. The IR receiver then demodulates the IR light signal and converts it to the binary before it transfers the data to Croduino: Modulated IR signal is a series of IR light pulse switched on and off at a high frequency known as a frequency carrier. The frequency of the carrier used by most transmitters is 38 kHz, because it is rare in nature and can, therefore, be distinguished from environmental pollution. That is how the IR receiver will know that a 38 kHz signal is sent from the transmitter and not the environment. The reception diode detects all the IR frequencies but has a low-pass filter that only allows IR up to 38 kHz. The modulated signal is then amplified using a pre-amplifier and converted into a binary before sending it to Croduino. Each time you press a button on the remote controller, a unique hexadecimal code is generated. This is a piece of information that is modulated and sent through the IR receiver. To decode which button is pressed, the receiving microcontroller must know which code corresponds to which button on the remote controller. Different remote controllers send different button codes, so you will have to determine the code generated for each button on your remote control. If you can find the datasheet, the IR codes of the buttons should be listed there. If it does not exist, there is a simple Croduino connection that will read most of the popular remote controllers and print hexadecimal codes to the serial monitor when you press the button. In the following section, we will show how to make a remote controller detection connection and a simple connection as an example that lights up and extinguishes LEDs.

How to connect?

The first connection will serve to detect buttons of any other remote controller we want to use. Our IR receiver, when viewed from the front (black dot with an X), has 3 pins. The first from the left is the IN that we connect to the digital input 7, in the middle is the GND that we connect to GND of the Croduino and finally, on the right, the VCC that we connect to + 5V of the Croduino. The image shows a connection without the board, if you want to connect it to the breadboard, the order of the connectors is the same, it only serves to see if the IR receiver received a signal so that the red LED illuminates. Now, we will show you a simple connection, using which you can use the IR remote controller to control Croduino output pins. In this example, we will illuminate the LED when we press a certain button. You can easily change the code to be able to control the electromotor or activate the relays by any press of a button on the remote controller. For this connection, besides the IR receiver, we will also need LED diodes and resistors. While connecting, make sure to check the diode's polarity. The IR is connected the same as in the previous connection: the first pin on the Digital Pin 7, the middle pin to the GND and the last one (on the right) to + 5V of the Croduino. Now, within the connection, we also have 2 LED diodes. To the Anode of the first LED (red) we connect Croduino's Digital pin 10, and to the cathode a resistor of 1 kilo ohm and to Croduino's GND, the same applies to another LED (green), only this time anode is connected to Digital pin 11, cathode to the resistor and from the resistor to Croduino's GND.

Arduino library and code

To program the IR Receiver, you will need an IRemote library for Croduino that you can download HERE. Button Detection Code: Now press each button on the remote controller and note the hexadecimal code printed each time you press the button, the code will be printed on the serial monitor.
#include "IRremote.h" //IR receiver library
const int RECV_PIN = 7; //IR declaration
IRrecv irrecv(RECV_PIN); // creates a receiver object with a name of your choice.
decode_results results; // Trying to receive the IR code. Returns true if the code is received or
//false if nothing has been received yet. When the code is sent, the data is
//saved to "results".
void setup(){ //Serial monitor
Serial.begin(9600); // opens a serial port, setting the data transfer rate to 9600
irrecv.enableIRIn(); //Reception procedure starts. This will allow the interruption
//of the timer that spends small amount of CPU each 50 μs
irrecv.blink13(true); //Allows blinking of the LED during the reception. Since you can not
//see the infrared light, the blinking LED can be useful for
//solving problems or for visual feedback only.
The code for simple connection with LED diodes: The code below will include the digital pin 10 HIGH for 2 seconds when the "5" button is pressed and the digital pin 11 HIGH on for 2 seconds when you press the button "2".
#include "IRremote.h" //IR receiver library
const int RECV_PIN = 7; //IR declaration (as in the previous example)
IRrecv irrecv(RECV_PIN);
decode_results results;
const int redPin = 10; //Red diode declaration
const int greenPin = 11; //Green diode declaration
void setup(){
irrecv.enableIRIn(); //the same as in the previous example
pinMode(redPin, OUTPUT); //pins set to be the output/source for the red LED diode
pinMode(greenPin, OUTPUT); //the same applies to the green diode
void loop(){
if (irrecv.decode(&results)){
case 0xFF38C7: //Button "5" code
digitalWrite(redPin, HIGH); //lights up the red diode
delay(2000); //keeps it illuminated for 2 seconds
digitalWrite(redPin, LOW); //turn off the red diode
case 0xFF18E7: //Button "2" code
digitalWrite(greenPin, HIGH); //lights up the green diode
delay(2000); //keeps it illuminated for 2 seconds
digitalWrite(greenPin, LOW); //turns off the green diode