Go Down

Topic: Button Sequence question (Read 1 time) previous topic - next topic

Elduderino

#10
Jan 26, 2013, 08:30 pm Last Edit: Jan 26, 2013, 08:39 pm by Elduderino Reason: 1
Not really.  I only need it to do a check once all characters in the code have been entered.  Sorry about the format, new to forums.  I'll try and fix it.

0AlphaOmega

PaulS point is interesting: There are commercial door entry units out there that check the code automatically after the correct count is entered, not requiring a 'enter' button (usually A or B)- fine! - However they then bubble the code up the array and pop the new number in at the bottom. The code is checked again!

thus:
code 1234
user enters 91234752 and gains entry, whereas we would expect the buffer to hold 4752 and fail! (door access usually lasts 7 sec)

This strange behaviour is then compounded by timing-out after n wrong tries (without a visual warning, although a grunt is issued on a fail, lamp-change for success). The next user hits the pad with the correct code and is already bared, so they start going through all the codes they have ever used, anywhere, lottery numbers, granny's birthday etc. The unit comes back on line and hey presto, locks them out again!

Point being, ensure the keypad is helpful and your users understand what it is trying to tell them.
For whom does the clock pulse? It pulses for you!

HazardsMind

Your not denouncing your buttons, so you might be getting multiple 1's, 2's and 3's on the serial monitor. And if that is the case, then they will all go into your array and mess up your password.
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Elduderino

Yeah this is just mainly a proof of concept code so that I can understand the interaction of arrays, the 300ms delay after each button press does a decent job of keeping the numbers from repeating(provided they're not held down).  I'm not sure if it's good form, but it works for this test.  In the future, on my final project, I'll have a proper debounce.

PaulS

Quote
In the future, on my final project, I'll have a proper debounce.

I suspect that edge detection will prove even more useful. Detect when a switch is pressed now and was not pressed before. This, of course, requires that you record the state between iterations of loop(), in a static or global variable.

300 milliseconds is far longer than even a cheap switch will bounce, but is not longer than a use might press a switch, thinking that it counts as only one press.

Go Up