> For the complete documentation index, see [llms.txt](https://longer-vision-robot.gitbook.io/arduino-full-stack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://longer-vision-robot.gitbook.io/arduino-full-stack/04_infrared_sensors/005_infrared.md).

# 4.1 Infrared Emitter and Receiver

## Hardware Wiring

![Infrared Emitter and Receiver](/files/-LCFE9HUuK6smz06SaMU)

## Sketch

The code can be found at [Examples\_Arduino - sensor-kit-for-arduino - \_005\_IRRemote\_Emit - \_005\_IRRemote\_Emit.ino](https://github.com/LongerVisionRobot/Examples_Arduino/blob/master/sensor-kit-for-arduino/_005_IRRemote_Emit/_005_IRRemote_Emit.ino) and [Examples\_Arduino - sensor-kit-for-arduino - \_005\_IRRemote\_Receive - \_005\_IRRemote\_Receive.ino](https://github.com/LongerVisionRobot/Examples_Arduino/blob/master/sensor-kit-for-arduino/_005_IRRemote_Receive/_005_IRRemote_Receive.ino) .

### Emit

```
#include <IRremote.h>
IRsend irsend;
void setup()
{
  Serial.begin(9600);
}
void loop() {
  for (int i = 0; i < 50; i++) {
    irsend.sendSony(0xa90, 12); // Sony TV power code
    delay(40);
  }
}
```

### Receive

```
#include <IRremote.h>
int RECV_PIN = 11; //define input pin on Arduino
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}
void loop() {
  irrecv.decode(&results);
  Serial.println(results.value, HEX);
if (irrecv.decode(&results)) {
  Serial.println(results.value, HEX);
  irrecv.resume(); // Receive the next value
  }
}
```
