Code: Select all
import config
itemp=config.temp
ihum=config.hum
def inctmp(p):
itemp = itemp + 1
def dectmp(p):
itemp = itemp - 1
p0 = Pin(0, Pin.IN)
p0.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=inctmp)
p15 = Pin(15, Pin.IN)
p15.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=dectmp)
whenever try to do hardware interrupt using push button getting following error.
Traceback (most recent call last):
File "<string>", line 24, in inctmp
NameError: local variable referenced before assignment
I am using itemp and ihum in other code.