# pinMode

## 函数原型

```cpp
void pinMode(uint8_t pin, uint8_t mode);
```

## 作用

在使用引脚前，需要先使用 `pinMode()` 定义引脚的模式。

## 参数

* `pin`

  指定引脚的编号，如： `10` , `A0` 等。
* `mode`

  指定引脚的模式。

其中，`mode` 可以是以下值：

| 模式             | 名称     | 介绍                                                           |
| -------------- | ------ | ------------------------------------------------------------ |
| `INPUT`        | 输入模式   | 可以读取该引脚的电位                                                   |
| `OUTPUT`       | 输出模式   | 可以控制该引脚的输出                                                   |
| `INPUT_PULLUP` | 输入上拉模式 | 启动板载电阻，使该引脚可以直接连接 5V 电压而不需要在之间另加电阻，但**不能接负电位，不能接大于 5V 的电压。** |

## 示例

```cpp
pinMode(3, INPUT);          // 设置 3 号引脚为 输入模式
pinMode(4, OUTPUT);         // 设置 4 号引脚为 输出模式
pinMode(5, INPUT_PULLUP);   // 设置 5 号引脚为 输入上拉模式
```


---

# 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://arduino.doc.skyone.host/core/io/pinmode.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.
