Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

MicroPython • Re: Pico Pin.IN problem

$
0
0
Why handle each input and LED separately when you can also use a 'for' loop there ...

Code:

while True:  for i in range(len(leds)):    if vu_meter[i].value() == 1:        leds[i].value(1)    else:        leds[i].value(0)
It wouldn't surprise me if you can optimise that even further but don't have a MicroPython on hand to try it -

Code:

while True:  for i in range(len(leds)):    leds[i].value( vu_meter[i].value() )

Statistics: Posted by hippy — Sun Mar 02, 2025 5:51 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles