Relsqui comments on Have no heroes, and no villains - Less Wrong

88 Post author: PhilGoetz 07 November 2010 09:15PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (73)

You are viewing a single comment's thread. Show more comments above.

Comment author: Relsqui 10 November 2010 04:54:42AM 2 points [-]

Or, as as David pointed out, treat it as a bozo byte.

Comment author: kpreid 14 November 2010 07:51:55PM *  1 point [-]

I'm reminded by the mention of byte-instead-of-bit and resetting after time of an algorithm for switch debouncing I heard about:

Keep a state of some number of bits (the word size of the microcontroller you're implementing it on, say), which are regular samples of the state of the switch (that is, state ← (state << 1) | (current_input ? 1 : 0)). Then consider the switch to be logically pressed if any of the bits are 1 (that is, the entire state is not zero) or perhaps if all of them are (whatever fits the application better). This produces a minimum pulse width of sample rate × number of state bits; it's just a nicely simple way of filtering the digital signal using CPU primitives.