I am from C/C++ background and newbie to python.
I have written a code, need your help to solve the issue...
he below code if written in While True: super loop, no issues at all.. but error comes when i put it inside blinkLED() function... below i the code:
Code: Select all
import time
import board
import digitalio
intervalLED = 0.5
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
ledState = False
previousMillisLED = 1
currentMillisLED = 1
def blinkLED():
currentMillisLED = time.monotonic()
if currentMillisLED - previousMillisLED >= intervalLED:
previousMillisLED = currentMillisLED
if ledState:
print("YES")
ledState = False
else:
print("NO")
ledState = True
led.value = ledState
while True:
blinkLED()
Regards,
Shri