> For the complete documentation index, see [llms.txt](https://s761111.gitbook.io/raspi-sensor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://s761111.gitbook.io/raspi-sensor/pigpio.md).

# 遠端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)
```
