What am I missing here? Thanks, Steve
------------------------------------
# Flash3.py
# import pyb # Done by <boot.py>
class IntLed(pyb.LED): # Internal led's on pyBoard
def __init__(self, id, trig=8):
super().__init__(id)
self.trig=trig
self.cntr=0
def flashLed(self): # Flash led when <cntr> = <trig>, then reset <cntr> to 0, <cntr> increments every 250 ms
self.cntr += 1
if self.cntr == self.trig:
self.toggle()
self.cntr = 0
led1=IntLed(1) # Make two instances of internal led's (ignore the other 2 for now)
led2=IntLed(2, trig=4)
leds= [led1, led2] # List of internal led's
def flashLeds():
for led in leds: # ********** This for loop, using the list, does not work
led.flashled()
# led1.flashLed() # ********** but calling them individually (with no for loop) does!
# led2.flashLed()
tmr = pyb.Timer(1) # Timer instance, use timer #1
tmr.init(freq=4) # 4 Hz --> interrupt every 250 ms
tmr.callback(lambda t:flashLeds())