> 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/thai/biboard/demo-applications/1.gpio-port.md).

# 1.GPIO port

Operate the GPIO port of BiBoard

ไม่มีพอร์ต GPIO แยกต่างหากบน BiBoard แต่พอร์ตซีเรียลแบบมัลติเพล็กซ์ 2 (พิน 16, 17) หรือพิน PWM ของอินเทอร์เฟซเซอร์โว PWM ที่ไม่ได้ใช้สามารถใช้เป็นพอร์ต GPIO ได้ พอร์ต GPIO นั้นค่อนข้างใช้งานง่าย หลังจากกำหนดค่าโหมดอินพุตและเอาต์พุตแล้ว การใช้งานจะเหมือนกับ Arduino UNO ทุกประการ คุณสามารถใช้โปรแกรมควบคุม IO ของ Arduino UNO อะไรก็ได้ เพียงแค่เปลี่ยนจำนวนของ IO

```c
/* In this demo, we use TX2, RX2 as general purpose IO
*   TX2 : IO17
*   RX2 : IO16
*/

void setup() {
  // initialize digital pin 16 & 17 as an output.
  pinMode(16, OUTPUT);
  pinMode(17, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    
  digitalWrite(16, HIGH);            // GPIO 16 & 17 HIGH
  digitalWrite(17, HIGH);
  delay(1000);                       // wait for a second

  digitalWrite(16, LOW);             // GPIO 16 & 17 LOW
  digitalWrite(17, LOW);
  delay(1000);                       // wait for a second
}
```


---

# 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/thai/biboard/demo-applications/1.gpio-port.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.
