19 lines
489 B
Python
19 lines
489 B
Python
'''
|
||
实验名称:点亮第1个LED
|
||
实验平台:核桃派
|
||
'''
|
||
import time
|
||
|
||
# 导入相关模块
|
||
import board
|
||
from digitalio import DigitalInOut, Direction
|
||
# 构建LED对象和初始化
|
||
while True:
|
||
led = DigitalInOut(board.CS1) # 定义引脚编号
|
||
led.direction = Direction.OUTPUT # IO为输出
|
||
print("熄灭")
|
||
led.value = 0 # 输出低电平,熄灭板载LED蓝灯
|
||
print("点亮")
|
||
time.sleep(20)
|
||
led.value = 1 # 输出高电平,点亮板载LED蓝灯
|