I'm new with LUA and nodemcu. I test with my esp-01, simple button and del.
My button ( integrated DF-Robot button: +V -V and data) is in GPIO2
DEL is in GPIO0
First test: gpio.HIGH or gpio.LOH for DEL is ok
Second test :
bouton = 4 --> GPIO2
function onChangeup ()
print("pin moves high")
end
gpio.mode(bouton, gpio.INT)
gpio.trig(bouton, 'up', onChangeup) -- front montant
This work fine, the text is displayed.
But, in association, my lua code does not work. No text display :
bouton = 4 --> GPIO2
led = 3 --> GPIO0
etat = 0
gpio.mode(led, gpio.OUTPUT)
gpio.write(led, gpio.LOW)
function onChangeup ()
print("Changement d'etat du bouton - on attent le front montant")
if ( etat == 0 ) then
gpio.write(led, gpio.HIGH)
etat=1
else if ( etat ==1 ) then
gpio.write(led, gpio.LOW)
etat=0
end
end
gpio.mode(bouton, gpio.INT)
gpio.trig(bouton, 'up', onChangeup) -- front montant
the error is probably minimal, but I can not find

Can you help me please?
R. Suinot