JMB Active Member Licensed User Longtime User Feb 4, 2018 #1 I have a NodeMCU with a switch to ground on one of the pins. I've defined the pin as an input with a pullup resistor, and I've added a listener to the pin. When I press the switch, the listener code runs once - and that's it. It comes back with the correct pin. But it only responds once. The code is shown below. Code: Copy btn.Initialize(16, btn.MODE_INPUT_PULLUP) 'Using the internal pull up resistor to prevent the pin from floating. btn.AddListener("Btn_StateChanged") The Listener code... Code: Copy Sub Btn_StateChanged (State As Boolean) Log("state: ", State) Log("this code called") Dim p As Pin = Sender Log("Pin: ", p.PinNumber, ", state: ", State) End Sub Can anyone shed some light on this? Thanks! JMB
I have a NodeMCU with a switch to ground on one of the pins. I've defined the pin as an input with a pullup resistor, and I've added a listener to the pin. When I press the switch, the listener code runs once - and that's it. It comes back with the correct pin. But it only responds once. The code is shown below. Code: Copy btn.Initialize(16, btn.MODE_INPUT_PULLUP) 'Using the internal pull up resistor to prevent the pin from floating. btn.AddListener("Btn_StateChanged") The Listener code... Code: Copy Sub Btn_StateChanged (State As Boolean) Log("state: ", State) Log("this code called") Dim p As Pin = Sender Log("Pin: ", p.PinNumber, ", state: ", State) End Sub Can anyone shed some light on this? Thanks! JMB
Erel B4X founder Staff member Licensed User Longtime User Feb 4, 2018 #2 Your code is correct. The problem is somewhere else. Try it with a different pin. Upvote 0
JMB Active Member Licensed User Longtime User Feb 4, 2018 #3 Sorted. I changed pin. Should have thought of that myself! Thanks for your help. JMB Upvote 0