Overview:
When you were a kid, Have you ever questioned yourself on how does the remote control of your TV functions? Why do you have to point it directly at the TV? When you aim your remote at a neighbor’s house, does their TV change too?
So in this activity we are going to find on how does this work. With the use of HX1838 mounted infrared receiver and a remote control. We are going to divide this into two activities so that we can deeply understand on how this things work and dont worry because this activity is a straight forward activity which means it is a friendly activity for beginners.
Hardware Used:
You can buy all this Hardware at Createlabz.
Software Used:
Library Used:
Application Description:
Infrared radiation is a type of electromagnetic radiation, as are radio waves, ultraviolet radiation, X-rays and microwaves. Infrared (IR) light is the part of the EM spectrum that people encounter most in everyday life, although much of it goes unnoticed. For example, when you hit a button on your TV remote, an IR LED repeatedly turns on and off, 38,000 time a second, to transmit information (like volume or channel control) to an IR photo sensor on your TV. It is invisible to human eyes, but people can feel it as heat. It is below the human eye of the Electromagnetic Spectrum.
Process of IR Remote
A common modulation scheme for IR communication is something called 38kHz modulation. There are very few natural sources that have the regularity of a 38kHz signal, so an IR transmitter sending data at that frequency would stand out among the ambient IR. 38kHz modulated IR data is the most common, but other frequencies can be used.
When you hit a key on your remote, the transmitting IR LED will blink very quickly for a fraction of a second, transmitting encoded data to your appliance.
If you were to hook an oscilloscope up to your TV remote’s IR LED, you would see a signal similar to the one above. This modulated signal is exactly what the receiving system sees. However, the point of the receiving device is to demodulate the signal and output a binary waveform that can be read by a microcontroller. When you read the OUT pin of the HX1383 with the wave from above, you will see something like this:
To summarize and to imagine how the IR remote functions:
Application
In order to perform this activity. We used a HX1383 mounted infrared receiver and a remote control. You can order this module kit in https://createlabz.store/ which cost 145 pesos.
The first activity that we are going to do is to determine the codes that appear in your remote control. Just copy the codes and the schematic diagram in the”Set up the Hardware” and “Code”.
This are the codes that comes from my remote control, some of you might have other results which is okay because maybe you are using other remote control. This activity is so important because you will need this codes to perform the second activity in which we are going to display some text in the LCD(Liquid Crystal Display) using your remote control.
Problems Encountered with this module:
It is really important to do the first activity, based on my experience sometimes the remote control prints another codes. As you can see in the serial monitor, the E318261B and FFA25D both of this is the code for CH-, for CH are 511DBB and FF629D and so on. This just means that if do not perform the first activity, you’re IR remote will be faulty and it will sometimes malfunctions. Some of you might have another codes for the IR remote so you better try the activity first before going to the 2nd activity. So this will happen. Click the link: https://youtu.be/ESgZiZV8wuk
The second activity is to display text in the LCD using the buttons in the remote control. As you can see in the featured image, every button has a functions. When I press CH- the LCD prints “You have pressed the button CH-“, when I press + the LCD prints “You have pressed the button +” and…..
Set-up the Hardware:
Schematic Diagram for First Activity:
Schematic Diagram for 2nd Activity:
Code:
For Activity 1:
#include <IRremote.h> const int RECV_PIN = 7; IRrecv irrecv(RECV_PIN); decode_results results; void setup(){ Serial.begin(9600); irrecv.enableIRIn(); irrecv.blink13(true); } void loop(){ if (irrecv.decode(&results)){ Serial.println(results.value, HEX); irrecv.resume(); } }
For Activity 2:
#include <IRremote.h> #include <LiquidCrystal.h> const int RECV_PIN = 7; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); IRrecv irrecv(RECV_PIN); decode_results results; unsigned long key_value = 0; void setup(){ Serial.begin(9600); irrecv.enableIRIn(); irrecv.blink13(true); lcd.begin(16, 2); } void loop(){ if (irrecv.decode(&results)){ if (results.value == 0XFFFFFFFF) results.value = key_value; lcd.setCursor(0,0); lcd.clear(); switch(results.value){ case 0xFFA25D: lcd.print("You have pressed the Button CH-"); break; case 0xFF629D: lcd.print("You have pressed the Button CH"); break; case 0xFFE21D: lcd.print("You have pressed the Button CH+"); break; case 0xFF22DD: lcd.print("You have pressed the Button |<<"); break; case 0xFF02FD: lcd.print("You have pressed the Button >>|"); break ; case 0xFFC23D: lcd.print("You have pressed the Button >|"); break ; case 0xFFE01F: lcd.print("You have pressed the Button -"); break ; case 0xFFA857: lcd.print("You have pressed the Button +"); break ; case 0xFF906F: lcd.print("You have pressed the Button EQ"); break ; case 0xFF6897: lcd.print("You have pressed the Button 0"); break ; case 0xFF9867: lcd.print("You have pressed the Button 100+"); break ; case 0xFFB04F: lcd.print("You have pressed the Button 200+"); break ; case 0xFF30CF: lcd.print("You have pressed the Button 1"); break ; case 0xFF18E7: lcd.print("You have pressed the Button 2"); break ; case 0xFF7A85: lcd.print("You have pressed the Button 3"); break ; case 0xFF10EF: lcd.print("You have pressed the Button 4"); break ; case 0xFF38C7: lcd.print("You have pressed the Button 5"); break ; case 0xFF5AA5: lcd.print("You have pressed the Button 6"); break ; case 0xFF42BD: lcd.print("You have pressed the Button 7"); break ; case 0xFF4AB5: lcd.print("You have pressed the Button 8"); break ; case 0xFF52AD: lcd.print("You have pressed the Button 9"); break ; case 0xE318261B: lcd.print("You have pressed the Button CH-"); break; case 0x511DBB: lcd.print("You have pressed the Button CH"); break; case 0xEE886D7F: lcd.print("You have pressed the Button CH+"); break; case 0x52A3D41F: lcd.print("You have pressed the Button |<<"); break; case 0xD7E84B1B: lcd.print("You have pressed the Button >>|"); break ; case 0x20FE4DBB: lcd.print("You have pressed the Button >|"); break ; case 0xF076C13B: lcd.print("You have pressed the Button -"); break ; case 0xA3C8EDDB: lcd.print("You have pressed the Button +"); break ; case 0xE5CFBD7F: lcd.print("You have pressed the Button EQ"); break ; case 0xC101E57B: lcd.print("You have pressed the Button 0"); break ; case 0x97483BFB: lcd.print("You have pressed the Button 100+"); break ; case 0xF0C41643: lcd.print("You have pressed the Button 200+"); break ; case 0x9716BE3F: lcd.print("You have pressed the Button 1"); break ; case 0x3D9AE3F7: lcd.print("You have pressed the Button 2"); break ; case 0x6182021B: lcd.print("You have pressed the Button 3"); break ; case 0x8C22657B: lcd.print("You have pressed the Button 4"); break ; case 0x488F3CBB: lcd.print("You have pressed the Button 5"); break ; case 0x449E79F: lcd.print("You have pressed the Button 6"); break ; case 0x32C6FDF7: lcd.print("You have pressed the Button 7"); break ; case 0x1BC0157B: lcd.print("You have pressed the Button 8"); break ; case 0x3EC3FC1B: lcd.print("You have pressed the Button 9"); break ; } key_value = results.value; irrecv.resume(); } }
Code Breakdown:
#include <IRremote.h> #include <LiquidCrystal.h>
Libraries we used in this activity
const int RECV_PIN = 7;
In this line, we assigned the pin of the IR receiver. You can choose any pins in the arduino i just chose the pin 7 because later it will not be used in the pins of the LCD.
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal syntax, depends on your pinouts.
LiquidCrystal(rs, enable, d4, d5, d6, d7)
IRrecv irrecv(RECV_PIN); decode_results results; unsigned long key_value = 0;
For any IR communication using the IRremote library, first we need to create an object called irrecv and specify the pin number where the IR receiver is connected (line 3). This object will take care of the protocol and processing of the information from the receiver.
void setup(){ Serial.begin(9600); irrecv.enableIRIn(); irrecv.blink13(true); lcd.begin(16, 2); }
In the void setup() block, first we configure the serial monitor baud rate. Next we start the IR receiver by calling the IRrecv member function enableIRIn() (line 10).
case 0xFFFFFFFF
This are the codes that came from your remote control. In order to find the codes you must do the activity 1 first.
lcd.print("You have pressed the Button EQ");
This line if the output when you pressed the button EQ. You can edit the text. Just change the text inside the string “”.
key_value = results.value; irrecv.resume();
If we receive 0XFFFFFFFF from the remote, it means a repetition of the previous key. So in order to handle the repeat key pattern, I am storing the hex code in a global variable key_value every time a code is received:
At the end of the void loop() section, we call irrecv.resume() to reset the receiver and prepare it to receive the next code.
Conclusion:
The main purpose of this project was to share what I learned from this module. To carry out this project, you must follow the instructions I have given and understand through research. This is so useful because this is a fundamental project and when you go to the complicated projects, you will return to the fundamental part. You can also add or improve this project, depending on what you would like.
References:
https://www.livescience.com/50260-infrared-radiation.html
https://learn.sparkfun.com/tutorials/ir-communication
circuitbasics.com/arduino-ir-remote-receiver-tutorial
https://arduino-info.wikispaces.com/IR-RemoteControl
The post Displaying Received Commands from an Infrared (IR) remote control on a 16×2 LCD module appeared first on CreateLabz.