Hi, i am a newbie in python and am trying to make a gui to control how fast an LED blinks with a variable named "delay". i am using this code
from tkinter import * from tkinter import ttk import RPi.GPIO as GPIO import time root = Tk() redLED = 26 GPIO.setmode(GPIO.BCM) GPIO.setup(redLED, GPIO.OUT) global delay delay = .40 while True: GPIO.output(redLED, GPIO.HIGH) time.sleep(delay) GPIO.output(redLED, GPIO.LOW) time.sleep(delay) def Decrease_Time(): delay -= .05 def Increase_Time(): delay += .05 button_increse = ttk.Button(root, text = 'Increase', command = Increase_Time).pack() button_decrease = ttk.Button(root, text = 'Decrease', command = Decrease_Time).pack() root.mainloop()but i get this error when i press the Increase or decrease buttons
Error:UnboundLocalError: local variable 'delay' referenced before assignment
any help appreciated