GPIO
— 控制I/O引脚¶
使用示例¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # coding=utf-8
# This is a sample Python script.
import utime
from driver import GPIO
print("start led test")
gpio = GPIO()
leds=("led_r", "led_g", "led_b")
for i in range(5):
for led in leds:
gpio.open(led)
gpio.write(1)
utime.sleep_ms(200)
gpio.write(0)
utime.sleep_ms(200)
gpio.write(1)
utime.sleep_ms(200)
gpio.close()
print("end led test")
|
配置信息¶
board.jon 语法和功能的详细配置项信息请参考 BoardConfig — 硬件端口配置文件(board.json)详解 。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | {
"version": "1.0.0",
"io": {
"led_r": {
"type": "GPIO",
"port": 36,
"dir": "output",
"pull": "pullup"
},
"led_g": {
"type": "GPIO",
"port": 35,
"dir": "output",
"pull": "pullup"
},
"led_b": {
"type": "GPIO",
"port": 34,
"dir": "output",
"pull": "pullup"
}
},
"debugLevel": "DEBUG"
}
|