# 遠端GPIO：pigpio + piscope

利用pigpio daemon直接從遠端控制樹莓派的gpio腳位，這和之前利用傳送命令的方式有很大的不同。

{% embed url="<https://youtu.be/nYyUdI0jWSs>" %}

在撰寫前別忘了先安裝 pigpio 程式庫

執行前別忘了先啟動遠端樹莓派的pigpio daemon

```python
import pigpio
from time import sleep

pi = pigpio.pi('192.168.1.112')

pi.set_mode(17, pigpio.OUTPUT)

while True:
    pi.write(17, 0)
    sleep(1)
    pi.write(17, 1)
    sleep(1)
```


---

# 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://s761111.gitbook.io/raspi-sensor/pigpio.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.
