> For the complete documentation index, see [llms.txt](https://mbyzhang.gitbook.io/loongbian/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mbyzhang.gitbook.io/loongbian/io/adafruit-blinka-library/sample-programs/blink.md).

# 板载 GPIO 输出：闪烁 LED 灯

本样例使用了一个连接到板载 GPIO 接口的 LED 灯模块。Python 程序将会控制该 LED 灯闪烁。

## 硬件连线

| 模块角标            | 龙芯派接口      | Python 引脚常量名 |
| --------------- | ---------- | ------------ |
| VCC/IN (LED 正极) | P13: GPIO2 | GPIO2        |
| GND (LED 负极)    | P9: GND    |              |

## 代码

```python
import time
import board
import digitalio

led = digitalio.DigitalInOut(board.GPIO2)
led.direction = digitalio.Direction.OUTPUT

while True:
    led.value = not led.value
    time.sleep(0.5)
```

程序运行后，LED 灯将会闪烁。

您也可以将 LED 灯替换为蜂鸣器，继电器等模块。
