> For the complete documentation index, see [llms.txt](https://docs.petoi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.petoi.com/chinese/biboard/li-cheng/7.-hong-wai-yao-kong.md).

# 7. 红外遥控

BiBoard配置了红外传感器，连接在第23引脚。红外的使用和基于AVR的UNO完全一样。

首先下载2.6.1版本的IRremote库，需要手工选择2.6.1版本。因为之后的版本红外编码有变化，如果使用3.X版本，指令会无法被翻译。为了同我们之前的产品兼容，测试后决定使用2.6.1版本。

![](https://201656985-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQ6a951Q6Jn1Zzt5Ajr%2F-MX3cdocpV97XkAb0q9k%2F-MX3dEbaFtWAxhy0O4mc%2Fimage.png?alt=media\&token=e8a9924c-322e-487d-b3fe-ed61a5c16f2b)

在使用NyBoard的时候，为了保证代码可以顺利编译，我们需要给IRremote库进行“瘦身”，即去掉我们用不到的编码/解码器，只保留NEC\_DECODER即NEC格式的38KHz信号解码器。

在Flash巨大的BiBoard上，我们无需进行“瘦身”。

![UNO使用了23%的Flash](https://201656985-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQ6a951Q6Jn1Zzt5Ajr%2F-MX3cdocpV97XkAb0q9k%2F-MX3eeH11NmVROtpAZva%2Fimage.png?alt=media\&token=4cb5d248-19b4-45e9-a24b-47a6bd7d4fbe)

![BiBoard只使用的4%](https://201656985-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQ6a951Q6Jn1Zzt5Ajr%2F-MX3cdocpV97XkAb0q9k%2F-MX3eOhuD7etiCi0wsCt%2Fimage.png?alt=media\&token=2df908bf-2f02-4b18-b16c-26127385305a)

最后附上例程，接受红外信号并串口打印，也可以使用官方的例程进行测试。

```
#include <Arduino.h>
#include <IRremote.h>

int RECV_PIN = 23;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  Serial.begin(115200);
  irrecv.enableIRIn();
  Serial.println("IR Receiver ready");
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    Serial.print(" - ");
    irrecv.resume(); // Receive the next value
  }
  delay(300);
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.petoi.com/chinese/biboard/li-cheng/7.-hong-wai-yao-kong.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
