How to Connect an IR Receiver to an Arduino

게시자

It's only been a few decades since “traditional” TV/VCR/stereo control via infrared (IR) light came onto the scene in the 1980s. While not the most advanced remote-control method now available, it’s inexpensive, and it usually works. Its simplicity means that Arduino IR remote control projects can be implemented for around a dollar for the receiver, plus any spare remote that you have lying around unused.

IR Remote Arduino Library: Accessing Remote Code

Arduino IR Remote Image 2

Arduino IR Remote Image 3

To use an IR receiver with your Arduino board or other microcontrollers like the ATtiny85 or ATtiny84, first install the IRremote library by Ken Shirriff. This can be found by searching for irremotelibrary through the Arduino library manager, or it’s available on GitHub here. When installed, you’ll have access to several new examples under File-Examples-IRremote.

For this control experiment, you can use an Arduino Uno, along with a Vishay TSOP4838 IR Remote Receiver. This particular receiver is designed to work with signals in the 38kHz range, and filters out most naturally occurring light, while demodulating signals from standard consumer remote control units. The TSOP4838’s supply pin is connected to Arduino 5V, ground to ground, and its output pin to Arduino pin 11.

관련 상품 참조

A000066 | Arduino Uno Rev3

Arduino Corporation Embedded System Development Boards and Kits 보기

관련 상품 참조

TSOP4838

Vishay IR Remote Receivers 보기

Open up the IRrecvDemo example and upload it to your board. With the Arduino still connected, open the serial monitor via Tools-Serial Monitor or Ctrl+Shift+M, and you’ll see a couple initial messages about the enabled IR input. Grab a remote—pretty much any remote—point it at the TSOP4838 and press a button. You’ll see the IR code pop up on the terminal in hexadecimal, indicating that it’s reading properly.

Arduino IR LED Control

To make this a little more fun, you can even add feedback from the built-in LED. You can probably figure out how to do that, but this lightly modified version of Shirriff's code produces LED feedback on the built-in LED with the push of any button. It’s not what you’d want in most situations, but it does prove that things are working.

Setting Arduino IR Remotes to Respond to Individual Codes

Arduino IR Remote Image 4

Of course, the real power of this type of remote is that it can change the channel, volume, robot position or anything else. The next step is to identify the button you want to use and have your Arduino respond when it sees this input. The earlier example identifies your particular remote codes, and this expanded version adds switch case statements to trigger different actions.

This code presents three code input options, as well as a default “Unknown code” scenario that’s activated when it doesn’t recognize what has been sent. These options can be copied, deleted and modified as needed, and you’ll probably want to set the output to something more interesting than giving you feedback about the button that was pressed. Substitute in your own remote codes to activate each option. Note that this setup can work with different types of remotes, even using different brands or styles in the same program.

Once you’ve mastered controlling an Arduino via an external infrared controller, you can also use the Arduino itself to generate these signals. This could allow it to control another custom receiver setup, or even act as a universal Arduino IR remote control.


최신 뉴스

Sorry, your filter selection returned no results.

개인정보 보호정책이 업데이트되었습니다. 잠시 시간을 내어 변경사항을 검토하시기 바랍니다. 동의를 클릭하면 Arrow Electronics 개인정보 보호정책 및 이용 조건에 동의하는 것입니다.

당사의 웹사이트에서는 사용자의 경험 향상과 사이트 개선을 위해 사용자의 기기에 쿠키를 저장합니다. 당사에서 사용하는 쿠키 및 쿠키 비활성화 방법에 대해 자세히 알아보십시오. 쿠키와 추적 기술은 마케팅 목적으로 사용될 수 있습니다. '동의'를 클릭하면 기기에 쿠키를 배치하고 추적 기술을 사용하는 데 동의하는 것입니다. 쿠키 및 추적 기술을 해제하는 방법에 대한 자세한 내용과 지침을 알아보려면 아래의 '자세히 알아보기'를 클릭하십시오. 쿠키 및 추적 기술 수락은 사용자의 자발적 선택이지만, 웹사이트가 제대로 작동하지 않을 수 있으며 사용자와 관련이 적은 광고가 표시될 수 있습니다. Arrow는 사용자의 개인정보를 존중합니다. 여기에서 당사의 개인정보 보호정책을 읽을 수 있습니다.