2023-12-26 17:06:05 +08:00
|
|
|
|
'''
|
|
|
|
|
实验名称:点亮第1个LED
|
|
|
|
|
实验平台:核桃派
|
|
|
|
|
'''
|
2023-12-26 17:06:31 +08:00
|
|
|
|
import time
|
2023-12-26 17:03:11 +08:00
|
|
|
|
|
2023-12-26 17:12:04 +08:00
|
|
|
|
# 导入相关模块
|
2023-12-26 17:06:05 +08:00
|
|
|
|
import board
|
|
|
|
|
from digitalio import DigitalInOut, Direction
|
2023-12-26 17:12:04 +08:00
|
|
|
|
# 构建LED对象和初始化
|
|
|
|
|
while True:
|
2023-12-26 17:13:57 +08:00
|
|
|
|
led = DigitalInOut(board.LED) # 定义引脚编号
|
2023-12-26 17:13:24 +08:00
|
|
|
|
led.direction = Direction.OUTPUT # IO为输出
|
2023-12-26 17:12:04 +08:00
|
|
|
|
led.value = 0 # 输出低电平,熄灭板载LED蓝灯
|
2023-12-26 17:15:04 +08:00
|
|
|
|
print("熄灭")
|
2023-12-26 17:13:04 +08:00
|
|
|
|
time.sleep(20)
|
2023-12-26 17:12:04 +08:00
|
|
|
|
led.value = 1 # 输出高电平,点亮板载LED蓝灯
|
2023-12-26 17:15:04 +08:00
|
|
|
|
print("点亮")
|