【发布时间】:2021-07-17 02:35:56
【问题描述】:
我使用下面的 Python 代码为 Raspberry Pi 4 让 LED 灯连续闪烁,但我只闪烁大约 10 次然后停止。我需要它不断闪烁。
import RPi.GPIO as GPIO
import time
redLED = 4
GPIO.setmode(GPIO.BCM)
GPIO.setup(redLED, GPIO.OUT)
try:
while True:
GPIO.output(redLED, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(redLED, GPIO.LOW)
time.sleep(0.5)
finally:
GPIO.cleanup()
【问题讨论】:
标签: python raspberry-pi raspberry-pi4