- Sat Mar 14, 2015 2:41 pm
#11974
picstart is correct
U should add a kind of delay and only read pin after about 100mS after button pressed, the first mS since button pressed are unstable.
interrupt detected -> delay 100mS -> read pin
pin=4
function start_delay()
tmr.alarm(0, 100, 0, function() print(gpio.read(pin)) end )
end
gpio.trig(4, "both",start_delay)
Report if this works
Other point is that using interruption it consumes some processing when triggered. During first mS of button pressed the input oscilates between 0 and 1 a lot of times.
So interrupt is called lots of times consuming much more processing power
U can add a periodic pin read for example each 300mS and if press detected call some function to something(better also add 100mS debounce time) Reading io each 300mS consume of very few proessing power, and u can read many pins at same time, and call function for each pin
See also
https://github.com/nodemcu/nodemcu-firm ... en#nodekeyhttps://github.com/nodemcu/nodemcu-firm ... w_gpio_mapRegards,Vito