CONTROLLING AN LED WITH TSOP1738 AND ARDUINO
Hey there guys, it’s your hardware friend kayode and together today we will be focusing on the TSOP1738 IR receiver. The TSOP1738 belongs to the TSOP17xx family. The xx represents the modulating frequency which in the case of the TSOP1738 is 38Khz. IR Transmitter and receiver is used to control any device wirelessly. We make use of them daily in our various homes. Television remote and Television are the best example of IR transmitter and receiver we can find around. TV generally consist TSOP1738 as the IR receiver, which senses modulated IR pulses and convert them into electrical signal.
- Photo Detector, IR Filter, Preamplifier and PCM frequency filter in one package
- CMOS and TTL Compatible
- Active Low Output
- Immunity against ambient light
- Low Power Consumption
- Able to transfer data continuously up to 2400bps
- Supply Voltage : 4.5 – 5.5V
- Internal filter for PCM frequency
Working principle of the TSOP1738
When the IR remote is pressed it sends out IR radiation. The TSOP1738 detects the IR which is switching on and off at the rate of 38Khz. TSOP’s output is active low, means its output will continue to remain HIGH when there is no IR, and becomes low when it detects IR radiation. So as to eliminate interference, the TSOP1738 operates at a particular frequency so that other IRs in the environment can’t interfere, except the modulated IR of particular frequency.
We will need the following components in order to work with the TSOP1738
Connect the above mentioned components as shown in the schematics below
The TSOP1738 has three pins from left to right as shown above are Gnd, Vcc and output. The Gnd pin of the TSOP1738 is connected to the ground of the arduino, the Vcc is connected to the 5v supply of the arduino and the output pin is connected to digital pin 11 of the arduino. The anode of the LED is connected to digital pin 13 while the cathode is connected to ground. The led that serves as our load is connected to digital pin 12 via 220R resistor.
NOTE: No current limiting resistor is used for the LED since pin 13 already has an in-built resistor. If any other pin is used, a current limiting resistor must be used.
Decoding IR Remote Control Signals using Arduino
When any button of the IR Remote is pressed, the remote sends a code in form of train of encoded pulses using 38Khz modulating frequency. These pulses are received by TSOP1738 sensor and read by Arduino and then Arduino decodes received train of pulse into a hex value and in turn will display it on the serial monitor.
Before we step into the code we have to do the following
- Download the IR remote library from here
- Unzip it, and place it in your Arduino ‘Libraries’ folder.
Run the below program from your Arduino and open the Serial Monitor window in Arduino IDE. Now press any IR Remote button and see the corresponding decoded hex output in Serial Monitor window. You should see something like the screenshot shown below if you did everything correctly.
We will do a little breakdown of the code and i will leave you with the code at the end. First, we are going include the IR remote library and also declare the pins we will be connecting things to.
Next, we will setup serial communication and also display some information on the serial monitor for debugging purposes and also to enable the led to blink during reception since we can’t see infrared blinking the led can help us to troubleshoot. We also set the led as output and make its initial state low.
Finally, in our void loop() section, data is received from the TSOP1738 and it is converted into hexadecimals and printed on the serial monitor. When the appropriate button is pressed on the remote the led comes on else it goes off.
So that will be all guys contact me if you have any question. Till next time, Keep creating and hacking.