Pages: [1]   Go Down
Author Topic: Single pin Analog 4x3 Keypad Password help please  (Read 630 times)
0 Members and 1 Guest are viewing this topic.
UK Norfolk
Offline Offline
Newbie
*
Karma: 3
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all I have an Arduino UNO I am making a home alarm system(after a spate of burglaries in our street)  have built an analog 4x3 keypad which uses just 1 pin. It works fine although my programming leaves a lot to be desired. The keypad returns these values 1=58, 2=96,,3=145, 4=228 ,5=335, 6=447,7=598,8=720,9=809,*=890 ,0=941,#=970. I have a program that  prints the numbers 1,2,3,etc. to the serial monitor. I do not have a LCD display. I have spent many hours researching and only find keypads with many pins. I keep on  trying but I am getting nowhere. There seems to be very little on the internet on this but considering the amount of pins keypads gobble up I am surprised more people are not using them.
I can assign one button turn the alarm on and one to turn it off but I cannot work out how to make a password. I have used the example password sketch with a 7 wire keypad and have had that working. The problem with that is that it uses too many pins. That is why I built an analog keypad. I would appreciate any advice you can give me. Please do not tell me to buy an alarm system like someone suggested on another group as I am disabled and have a very low income.
Thanks
Jeremy
Hopefully I have managed to attach some code of the buttons I have adapted from some code posted by a guy called Riaan Cornelius. It is very messy (sorry)

* Analog_keypad.ino (5.65 KB - downloaded 8 times.)
Logged

There are times when electronics projects are like Women. Just when you think everything is fine the blow up in your face :-0

UK
Offline Offline
Shannon Member
****
Karma: 183
Posts: 11129
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to enter a 'password' then you need to read a sequence of keys and buffer them until the password is complete, and then validate it. You will need some way to tell when the sequence of entering the password starts and ends. For example, you might require the user to press the right sequence of keys within a time limit. You probably also want to provide some way to cancel the last key entered, or cancel the password entry completely. In order to be usable, I think you need to give the user feedback when you have started password input, when you have accepted a keypress as part of a password, and when the password has passed or failed validation, If you don't want to use a display then a sounder or flashing LED would be alternative options.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

UK Norfolk
Offline Offline
Newbie
*
Karma: 3
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Peter thank you I will definitely do that with an led or sounder. but the part about time limits  and when the sequence starts and ends is beyond my skills. I would appreciate a nudge in the right direction or point me to some books I could read to help me to implement the idea. I have had no luck in finding anything so far.
Thanks.
Jeremy
Logged

There are times when electronics projects are like Women. Just when you think everything is fine the blow up in your face :-0

UK
Offline Offline
Shannon Member
****
Karma: 183
Posts: 11129
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The concept of reading a 'password' from a keypad is conceptually very similar to the way serial port input is received, buffered and processed. I suggest you look at Nick Gammon's examples showing how to deal with serial port input.

In place of the Serial.available() and Serial.read() you would check for a keypress event and work out the ascii character code corresponding to the button that was pressed.

If you want to apply a timeout to the password entry then the approach would be to record the value of millis() when the password entry started, and then compare that with the value of millis() while you were waiting for the password entry to be completed. If the elapsed time exceeds your threshold then abandon the password entry and deal with the timeout as you see fit. The 'blink without delay' example sketch shows you exactly how to detect when an interval has elapsed and is more or less identical to the way you'd implement the timeout detection.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: