# 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
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://longer-vision-robot.gitbook.io/arduino-full-stack/04_infrared_sensors/005_infrared.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
