--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
int Debounce::update(){ uint8_t newState = digitalRead(pin); if (state != newState ) { if (millis() - previous_millis >= interval_millis) { previous_millis = millis(); state = newState; return 1; } }
I was reffering to Brian Ouellet Frederick' debounce Library:
int Debounce::update(){uint8_t newState = digitalRead(pin);if (state != newState ) {if (millis() - previous_millis >= interval_millis) {previous_millis = millis();state = newState;return 1;}}
It waits for interval_millis, It does not wait for the the switch to stop bouncing
If that's the actual code it has an obvious bug.
And, it delays after the first transition which, as I suggested, wreaks havoc for some applications.
This is what newbies are told to do on the Forum...
--
For example: what if you are using a resistor ladder to read 10 buttons on a single analog pin...you'll need a more versatile solution like what I've implemented here instead of just a button debounce library that does the reading inside of it. My library expects the user to pass in the bouncing value and the library will debounce it using millis().
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
Paul, would you mind posting a link to the library? Thanks in advance.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
May be there should be some broken examples that force the newbies to deal with this problem of figuring out why a switch needs to be denounced switch .
I have know this from college and have done my fair share of coding for denouncing switches.
It's too easy to program applications where don't have worry about all the got you that you would other wise have to face if you had code from scratch.
Another problem we have to deal with is Hysteresis which most don't under stand until you have to deal with it. I was part of project that was our key to
completing a project that other threw the towel in unknown to us at the time.
which -----Original Message-----
From: Jacques Bellavance
Sent: Sep 25, 2017 7:34 AM
To: Developers
Subject: [Developers] Adding a digitalDebounce(pin) function
Hi all,I have been around the Forum for a little while now, and I noticed that a lot of newbies are not aware that a switch should be debounced. And once they are aware, they have a hard time understanding the "standard" wait a little bit before confirming a state change way of debouncing.I understand that the whole Arduino environment is designed to help students and artists using technology for IoT and other uses. Switches are amongst the mostly used pieces of hardware in any setup to do IoT.For those reasons, I think that having a debouncer as part of the language would be a good idea. There are a lot of debouncing algorithms available, and I can see that it would be a hard to choose which one to use. Some are blocking, some are not. some are fast, some take more time to give a positive feedback. So, basically, there will be some pros and cons. What I suggest is just a new tool to deal with the problem without having to resort to include a Library (often regarded as a no no on the Forum) or to have to code it in the sketch every time one would use a switch.I would like to have your feedback on this.Thank you all.
--
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
I agree, hardware debounce is the best.
De : Andrew Kroll [mailto:xxx...@gmail.com]
Envoyé : 25 septembre 2017 17:35
À : Arduino Developers
Objet : Re: [Developers] Adding a digitalDebounce(pin) function
Here's my solution, works every time...
Enjoy the ASCII-ART schematic ;-)
1K
Ground <-o--/\/\/\/\--,
| .1uf
+-------||-------+----> to pin (INPUT_PULLUP)
| |
| / |
`------O o-------'
Visit my github for awesome Arduino code @ https://github.com/xxxajk
--
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--Visit my github for awesome Arduino code @ https://github.com/xxxajk
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
I got a bit overwhelmed with hardware debouncing when I read that article : http://www.ganssle.com/debouncing-pt2.htm
It was more complicated than the 1K resistor coupled with a .1uF capacitor and there you go son, have fun.
De : Alex Albino [mailto:aal...@femtoduino.com]
Envoyé : 25 septembre 2017 17:55
À : devel...@arduino.cc
Objet : Re: [Developers] Adding a digitalDebounce(pin) function
Hardware debouncing is the ideal way to do it... but keep in mind there are good reasons to support software debouncing, such as in designs where someone forgot to add hardware debouncing. :o)
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
Visit my github for awesome Arduino code @ https://github.com/xxxajk
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
Visit my github for awesome Arduino code @ https://github.com/xxxajk
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
If we do this, here's an example: https://www.arduino.cc/en/Tutorial/Debounce
But...we need to either #include a library for it, making each button an object so it can store "lastButtonState" and "lastDebounceTime" into the object's private variables, or we statically allocate arrays of these values for every button pin on the Arduino, in the core code, right?
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--Visit my github for awesome Arduino code @ https://github.com/xxxajk
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--Visit my github for awesome Arduino code @ https://github.com/xxxajk
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
That (multiple objects) does not need to be the case. Take a look at this Library: https://github.com/j-bellavance/EdgeDebounceLite
De : Gabriel Staples [mailto:panth...@gmail.com]
Envoyé : 25 septembre 2017 18:20
À : devel...@arduino.cc
Objet : Re: [Developers] Adding a digitalDebounce(pin) function
Correction in green below.
On Mon, Sep 25, 2017 at 6:17 PM, Gabriel Staples <panth...@gmail.com> wrote:
If we do this, here's an example: https://www.arduino.cc/en/Tutorial/Debounce
But...we need to either #include a library for it, making each button an object so it can store "lastButtonState" and "lastDebounceTime" into the object's private variables, or we statically allocate arrays of these values for every button pin on the Arduino, in the core code, right?
Actually, what I had in mind is me talking to my son. (I am 62 and he is 29).
De : Andrew Kroll [mailto:xxx...@gmail.com]
Envoyé : 25 septembre 2017 18:28
À : Arduino Developers
Objet : Re: [Developers] Adding a digitalDebounce(pin) function
Yes, R/S flip-flop is one of the more complex ones on the hardware end, but you really don't need it. Same for the one that inverts, you don't need to do that if you simply add a pull-down on the input and change ground d to V+....
Seen these before, and I don't really recommend using the R/S flip-flop at all. More complex than it needs to actually be.
I always have fun attempting to explain to clients why mechanical switches suck, and always recommend use of optical, even if we have to fabricate them.
As far as the "son" comment, LOL. I'm a bit older than you think ;-)
I've been doing this sort of thing for 4 decades, well before Arduino existed.
No offense taken, I found it quite funny being called "son". Next time use "Sonny", be cause I'm so bright (Sunny)! LOL!
Cheers :-)