> For the complete documentation index, see [llms.txt](https://mwx.twelite.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mwx.twelite.info/latest_en/api-reference/funcs/dio.md).

# DIO General purpose IO

The following functions are used for general-purpose digital IO (DIO) operations.

* `pinMode()`
* `digitalWrite()`
* `digitalRead()`
* `attachIntDio()`
* `detachIntDio()`

## Constants

### Pin name and number

| Definition                              | Name             |
| --------------------------------------- | ---------------- |
| `const uint8_t PIN_DIGITAL::DIO0 .. 19` | DIO pins 0 to 19 |
| `const uint8_t PIN_DIGITAL::DO0 .. 1`   | DO pin 0,1       |

### Mode of pin（DIO0..19)

The following enumeration values are handled with the type name `E_PIN_MODE`.

| Definition                      | Pull-up | Name                       |
| ------------------------------- | :-----: | -------------------------- |
| `PIN_MODE::INPUT`               |   None  | Input                      |
| `PIN_MODE::OUTPUT`              |   None  | Output                     |
| `PIN_MODE::INPUT_PULLUP`        |   Yes   | Input                      |
| `PIN_MODE::OUTPUT_INIT_HIGH`    |   None  | Output(init HIGH)          |
| `PIN_MODE::OUTPUT_INIT_LOW`     |   None  | Output(init LOW)           |
| `PIN_MODE::WAKE_FALLING`        |   None  | Input, raised pin, falling |
| `PIN_MODE::WAKE_RISING`         |   None  | Input, rising pin, rising  |
| `PIN_MODE::WAKE_FALLING_PULLUP` |   Yes   | Input, raised pin, falling |
| `PIN_MODE::WAKE_RISING_PULLUP`  |   Yes   | Input, rising pin, rising  |
| `PIN_MODE::DISABLE_OUTPUT`      |   Yes   | return to the input state  |

### Mode of the pin (DO0,1)

The following enumeration values are handled with the type name `E_PIN_MODE`.

| Definition                   | Name                        |
| ---------------------------- | --------------------------- |
| `PIN_MODE::OUTPUT`           | Contribute                  |
| `PIN_MODE::OUTPUT_INIT_HIGH` | Output (initial state HIGH) |
| `PIN_MODE::OUTPUT_INIT_LOW`  | Output (initial state LOW)  |
| `PIN_MODE::DISABLE_OUTPUT`   | Stop setting output         |

### pin\_state

The following enumeration values are handled with the type name `E_PIN_STATE`.

| Definition        | Value | Name             |
| ----------------- | :---: | ---------------- |
| `PIN_STATE::HIGH` |   1   | HIGH(=Vcc) level |
| `PIN_STATE::LOW`  |   0   | LOW(=GND) level  |

### Rising and falling edge of pin

The following enumeration values are handled with the type name `E_PIN_INT_MODE`.

| Definition              | Name         |
| ----------------------- | ------------ |
| `PIN_INT_MODE::FALLING` | falling edge |
| `PIN_INT_MODE::RISING`  | rising edge  |


---

# 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 dynamically by asking a question.

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

```
GET https://mwx.twelite.info/latest_en/api-reference/funcs/dio.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.
