-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State not correctly initialized for INPUT_PULLUP button #96
Comments
When attaching with a pull-up, the state should be 3. It almost seems like the state is being read before the pull-up is done... In the following code run when attaching,
|
Hi @thomasfredericks , don't know what to say, that's the result though. Did you test the sample code and get a different result? |
I tried to reproduce your error but I do not have a Teensy on hand. What version of Teensy are you using? Loop 0: pressed: 0, ispressed: 0
Loop 1: pressed: 0, ispressed: 0
Loop 2: pressed: 0, ispressed: 0
Loop 3: pressed: 0, ispressed: 0
Loop 4: pressed: 0, ispressed: 0
Loop 5: pressed: 0, ispressed: 0
Loop 6: pressed: 0, ispressed: 0
Loop 7: pressed: 0, ispressed: 0
Loop 8: pressed: 0, ispressed: 0
Loop 9: pressed: 0, ispressed: 0 If I hold down the button at bootup: Loop 0: pressed: 0, ispressed: 1
Loop 1: pressed: 0, ispressed: 1
Loop 2: pressed: 0, ispressed: 1
Loop 3: pressed: 0, ispressed: 1
Loop 4: pressed: 0, ispressed: 1
Loop 5: pressed: 0, ispressed: 1
Loop 6: pressed: 0, ispressed: 1
Loop 7: pressed: 0, ispressed: 1
Loop 8: pressed: 0, ispressed: 1
Loop 9: pressed: 0, ispressed: 1 I also tried with an Arduino Nano and got the same results... |
@navdotnetreqs This sounds like some capacitance on the Teensy's input slowly coming up (after you configure INPUT_PULLUP). I don't know how the MCU on the Teensy (which version are you using?) implements internal pull-ups, some are actual on-silicon resistors, other are little constant-current circuits which achieve the same result, but either way, it sounds like the input is taking some ~200ms to come up to a Hi input level. At first I thought it might've been because the Teensy (4.0/4.1) is so absurdly fast compared to the average Arduino, but you're doing delay(100), so that's 200+ ms for it to come up, which is rather long! |
Hi,
I have a panic stop button that is set to INPUT_PULLUP. So the pressed state is LOW.
I noticed that when I boot the board (Teensy) I get a false trigger that the button is pressed for the first update cycle.
The internal state-variable has weird values for three loops, after this the state stabilizes and it works as it should.
in setup()
With a limit switch pulled to ground the same loop goes
It seems to me the initial value of the protected Debouncer variable state should be initialized in setPressedState depending on if it's a LOW or HIGH actuated press.
As a workaround I changed the state to public, and set PanicBtn.state = 3 after setPressedState.
The text was updated successfully, but these errors were encountered: