Skip to content Skip to sidebar Skip to footer

Widget HTML #1

Tutorial TSOP1738 Arduino Infrared Remote For Control LED

IR Remote TSOP1738 Arduino Tutorial 

Tutorial TSOP1738 Arduino Infrared Remote  For Control  LED - IR Remote is a short-range wireless communication that is very widely used. Apart from its low price, this remote IR protocol is excellent.
 
To be able to read incoming infrared data, we must first know the protocol used. Protocol is simply the language of communication used.
 
There are 4 IR Remote Protocols that are most commonly used, namely the NEC, SONY, RC5 and RC6 protocols. One of the IR receiver or IR remote control receiver is TSOP1738.
TSOP1738, TSOP1738 Arduino, TSOP1738 ir remote, TSOP1738 ir remote control, TSOP1738 schematics, TSOP1738 code arduino, TSOP1738 led turn on, TSOP1738 led rgb, TSOP1738 arduino tutorial, TSOP1738 feature, rangkaian TSOP1738 arduino, kode program TSOP1738, cara menggunakan TSOP1738 arduino, how to use TSOP1738 arduino, TSOP1738 pinout, library for TSOP1738, library untuk TSOP1738, rangkaian tsop1738 arduino.
TSOP1738 Pin Out
 

A. TSOP1738 IR Receiver 

TSOP1738 is one of the IR receivers manufactured by VISHAY. This component  has a photo detector and preamplifier in one package, so it can be used directly on a microprocessor or microcontroller.
 
But in the remote ir application, it takes at least 3 additional components, namely resistors 100R, 10KR and Elko 4.7uF.
 
TSOP1738 Features:
  • Photo Detector and preamplifier in one package.
  • Internal filtering for PCM frequencies
  • Increased protection against electric field interference
  • TTL and CMOS compatibility
  • Active output low
  • Low power consumption
  • High immunity to ambient light
  • Continuous data transmission possible (up to 2400 bps)
  • Appropriate burst length ≥10 cycles / burst
 
Maximum Rating:
  • Supply Voltage up to 6V
  • Supply Current up to 5mA
  • Output Voltage up to 6V
  • Junction temperature 100 degrees C
  • Storage temperature up to +85 degrees C
  • Operating temperature up to +85 degrees C
  • Power up to 50mW
  • Soldering temperature up to 260 degrees C
 

 

B. Schematic of TSOP1738 Arduino

To be able to communicate between TSOP1738 and Arduino, please connect them as in the circuit below.

 

 
If you are a beginner and feel unfamiliar with the above schematic, you can try the ir receiver module which has been sold in the market.

C. TSOP1738 Arduino Library

Now, please download the library for Arduino ir. This library will make it easier for us to convert the signal received by the photo detector into Hexadecimal data.
 
 
After that, inlude the library that has been downloaded by:
  • Open the Arduino IDE
  • Click Sketch -> Include Library -> add .ZIP library
  • Navigate and select the library that you have downloaded
  • Click OK
 
In this library, there are basic commands that are very useful in implementing code. Here are the instructions.
 
Commands For Receiver:
  • IRrecv irrecv(receivePin)
    Create a recipient object, using a name of your choice.
  • irrecv.enableIRIn()
    Start the admissions process. This will activate a timer interrupt which consumes a small amount of CPU every 50 ┬Ás.
  • irrecv.decode(&results)
    Attempting to receive an IR code. Returns true if codes were received, or false if none were received. When the code is received, the information is stored in the "results".
    results.decode_type: Will be one of the following: NEC, SONY, RC5, RC6, or UNKNOWN.
    results.value: Actual IR code (0 if type UNKNOWN)
    results.bits: The number of bits used by this code
    results.rawbuf: an array of IR pulse timing
    results.rawlen: The number of items stored in the array
  • irrecv.resume()
    After receiving, it must be called to reset the receiver and prepare it to receive another code.
  • irrecv.blink13(true)
    Activate LED blinking during reception. Since you can't see infrared light, flashing the LED can be useful when troubleshooting a problem, or just to provide visual feedback.
 
Command For Transmitter:
  • IRsend irsend;
    Create a transmission object. A fixed pin number is always used, depending on which timer the library is using.
  • irsend.sendNEC(IRcode, numBits);
    Send code in NEC format.
  • irsend.sendSony(IRcode, numBits);
    Send code in SONY format.
  • irsend.sendRC5(IRcode, numBits);
    Send code in RC5 format.
  • irsend.sendRC6(IRcode, numBits);
    Send code in RC6 format.
  • irsend.sendRaw(rawbuf, rawlen, frequency);
    Send raw code. Usually you will get rawbuf and rawlen content by using the receiver many times and averaging the results.

    Several adjustments may be required for best performance. Frequency is the expected bandpass filter frequency at the receiver, of which 38 is the most commonly used.
 

D. TSOP1738 Arduino Code

1. Basic Program Receiving IR Remote Data

Okay ... now that we've loaded the library, we'll look at the basic program of receiving data. Here is the basic program. Please upload to Arduino.

Progam:

#include <IRremote.h>
const int RECV_PIN = 2; 
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);

irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {

Serial.println(results.value, HEX);

irrecv.resume();
}
}

After the upload is complete, open the Arduino IDE monitor serial. Make sure the baudrate is selected at 9600 (bottom right of the monitor serial).

Now press one of the remotes buttons. Then the serial monitor will display the address with a Hexadecimal value. 


2. See the IR Remote Protocol Type

Now, we will try to see the protocol used by your remote. As explained above, there are 4 remote IR protocols used, namely NEC, SONY, RC5 and RC6.
 
The program below will read the protocol type on the remote you are using, then it will be displayed on the serial monitor. Please upload the following program.

Program:

#include <IRremote.h>
const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true); 
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("Protokol NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("Protokol SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("Protokol RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("Protokol RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("Protokol tidak diketahui: ");
}
Serial.println(results.value, HEX);
irrecv.resume();
}
}

After the upload is complete, please press the button on the remote and point it to TSOP1738. You will see the type of protocol you are using on the serial monitor.

 

3. Turning on the RGB LED Using the Remote

After you understand the two programs above, we will try to turn on the 3 LEDs using the remote.

To turn on 3 Red Green and Blue LEDs we need three buttons. Let's say we have defined 3 hex addresses for the remote: 

  • 0xFF30CF hex data for red color
  • 0xFF18E7 hex data for green
  • 0xFF7A85 hex data for blue color

For the circuit, please connect the Red LED to pin 12, the Green LED to pin 11, and the blue LED to pin 10. Don't forget to use a 330R resistor.

Please upload the following program on your Arduino. Please press the button 1, 2, or 3 of your remote.

Program:

#include <IRremote.h>
const int RECV_PIN = 2; 
int ledMerah = 12;
int ledHijau = 11;
int ledBiru = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true); 
pinMode(ledMerah, OUTPUT);
pinMode(ledHijau, OUTPUT); pinMode(ledBiru, OUTPUT);
}
void loop() {
//Data hex 0xFF30CF for RED
//Data hex 0xFF18E7 for GREEN
//Data hex 0xFF7A85 for BLUE
 
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (results.value == 0xFF30CF)
{
digitalWrite(ledMerah, HIGH);
digitalWrite(ledHijau, LOW);
digitalWrite(ledBiru, LOW);
}
if (results.value == 0xFF18E7)
{
digitalWrite(ledMerah, LOW);
digitalWrite(ledHijau, HIGH);
digitalWrite(ledBiru, LOW);
}
if (results.value == 0xFF7A85)
{
digitalWrite(ledMerah, LOW);
digitalWrite(ledHijau, LOW);
digitalWrite(ledBiru, HIGH);
}
 
irrecv.resume(); 
}
}

 


 


 

E. TSOP1738 Datasheet

For more information about TSOP1738, you can see the TSOP1738 datasheet below.

 

Apart from TSOP1738, there is a component that is now widely used, namely VS1838B. You can read How to Use the TL18838 IR Remote.

Thank you for visiting the Piko Chip website. Hope it is useful.

Source: Arduino32

Post a Comment for "Tutorial TSOP1738 Arduino Infrared Remote For Control LED "