This is a blinky type program, I am trying to get my leds to light up in one direction and then the other. Without ther "leds.reverse()" line the program runs fine, that is it lights one led at a time in sequence. I('d like to get it to run backwards, by using the list reverse function, but when I do, it goes a little nuts. I cannot seem to be able to debug by printing the led pin#. If I print " print(leds[index])" the return is <PWM> or some such. I am thinking the issue is WHERE I place teh "leds.reverse()" function, but I cannot really tell what is going on. Is there a way to print the pin number?

Thanks,

Roger

- Code: Select all | TOGGLE FULL SIZE
`import board`

import pulseio

import time

l1 = pulseio.PWMOut(board.D1, frequency=500, duty_cycle=0)

l2 = pulseio.PWMOut(board.D2, frequency=500, duty_cycle=0)

l3 = pulseio.PWMOut(board.D3, frequency=500, duty_cycle=0)

l4 = pulseio.PWMOut(board.D4, frequency=500, duty_cycle=0)

l5 = pulseio.PWMOut(board.D5, frequency=500, duty_cycle=0)

l6 = pulseio.PWMOut(board.D6, frequency=500, duty_cycle=0)

l7 = pulseio.PWMOut(board.D7, frequency=500, duty_cycle=0)

l8 = pulseio.PWMOut(board.D8, frequency=500, duty_cycle=0)

l9 = pulseio.PWMOut(board.D9, frequency=500, duty_cycle=0)

l10 = pulseio.PWMOut(board.D10, frequency=500, duty_cycle=0)

l11 = pulseio.PWMOut(board.D11, frequency=500, duty_cycle=0)

l12 = pulseio.PWMOut(board.D12, frequency=500, duty_cycle=0)

leds = [l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12]

pattern1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

def duty_cycle_value(percent):

return int(percent * 65535)

i = 0

deltat = 1.00

initial = time.monotonic()

index = 0

while True:

now = time.monotonic()

if now - initial > .01:

if index == 0:

temp = pattern1[index]

if index < 11:

pattern1[index] = pattern1[index+1]

if index == 11:

pattern1[index] = temp

leds[index].duty_cycle = duty_cycle_value(pattern1[index])

# print(pattern1[index])

# print(leds[index])

index = index + 1

if index == 12:

index = 0

# leds.reverse()

initial = now