Я хочу, чтобы эта команда выполнялась с помощью цикла for с диапазоном.
Я использую PiGPIOFactory из модуля gpiozero.
Код: Выделить всё
test1 = LED(17)
test2 = LED(23)
test3 = LED(30)
for led in range (1,4):
sw_on = f"test{led}"
if sw_on.is_lit:
do smth
else:
do smth
Код: Выделить всё
sw_on.on()
^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'on'
Подробнее здесь: https://stackoverflow.com/questions/784 ... with-range