The code works fine for either of the functions defined but not when I use both ... han ?
here is the culprit code :
Code: Select all
# main.py -- put your code here!
import pyb
import os
import utime
_LOGFILE = "pyb_LOG2.txt"
RED = 1
GREEN = 2
YELLOW = 3
BLUE = 4
def log_this(that):
LOG = open(_LOGFILE, 'a') # as LOG:
LOG.write(that)
pyb.delay(100)
LOG.close()
def flash_LED(which, duration):
led = pyb.LED(which)
led.on()
pyb.delay(duration)
led.off()
flash_LED(YELLOW, 1000)
log_this("BootUP")
flash_LED(BLUE, 1000)
log_this("Done")
flash_LED(RED, 1000)
log_this("Real Done")
flash_LED(GREEN, 1000)
log_this("Yeah !")
flash_LED(YELLOW, 1000)
When I comment out the other one ... log_this ... the LED flash fine ...
But this code as is won't ... why ?????