How to Connect an IR Receiver to an Arduino

Pubblicato da

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.

Visualizza prodotti correlati

A000066 | Arduino Uno Rev3

Arduino Corporation Placas y kits de desarrollo del sistema integrado Visualizza

Visualizza prodotti correlati

TSOP4838

Vishay Receptor remoto IR Visualizza

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.


Ultime notizie

Sorry, your filter selection returned no results.

Non perderti le ultime novità sull'elettronica

Abbiamo aggiornato la nostra politica sulla privacy. Si prega di prendere un momento per rivedere questi cambiamenti. Cliccando su Accetto, l'utente accetta la Politica sulla privacy e Condizioni di utilizzo di Arrow Electronics.

Il nostro sito web mette i cookies sul vostro dispositivo per migliorare la vostra esperienza e il nostro sito. Leggete altre informazioni sui cookies che usiamo e su come disabilitarli qui. I cookies e le tecnologie di tracking possono essere usati per scopi commerciali.

Con un click su “Accept”, voi consentite l'inserimento dei cookies sul vostro dispositivo e l'uso da parte nostra di tecnologie di tracking. Per avere altre informazioni e istruzioni su come disabilitare i cookies e le tecnologie di tracking, clickate su “Read More” qui sotto. Mentre l'accettazione dei cookies e delle tecnologie di tracking è volontaria, una loro disabilitazione potrebbe determinare un funzionamento non corretto del sito web, ed alcuni messaggi di allarme potrebbero essere per voi meno importanti.

Noi rispettiamo la vostra privacy. Leggete qui la nostra politica relativa alla privacy