Custom Keypad with Display

Thread Starter

petro13

Joined Aug 21, 2015
2
Hi, i'm a complete novice regarding electronics, so please bear with me.
I want to make a keypad with a display that will control an electronic lock. I'm talking about a typical 4x4 security keypad and a simple 4-digit display, but i want the keypad to act in a different way. For example, the unlocking code is 1234, but the code numbers (that will be displayed on the screen) will not correspond to the numbers on the keypad, instead they will follow different rules, for example: 1 = 8,2 pressed in succession, 2 = 6, 3 = 4,1,5 pressed in succession etc.
I would like to know how hard would be to build such a device, and a general idea of how should i go about it, as i'm pretty sure i won't be able to do this myself.
Thanks in advance.
 

shteii01

Joined Feb 19, 2010
4,644
Yeah, should be pretty easy with Arduino. Just take Arduino microcontroller+keypad+lcd. Microcontroller receives input from keypad, based on the input it produces user desired value (number or letter or whatever), then sends the value to the LCD.

To produce desired value you will probably use several if statements.
If 1 received from keypad, send 8 to lcd.
If 2 received from keypad, send 6 to lcd.
etc.
This is the logic of the operation, the code would look something like this:
Code:
if(keypad_value==1) {lcd.print("8")}
if(keypad_value==2) {lcd.print("6")}
 

KerryJB

Joined Dec 17, 2012
2
Hello there Petro!

Given the example you mentioned, it sounds like entering the full 4-digit unlocking code could result in as many as 12 digits being displayed on the screen. (Unless you're thinking of having the user-entered digits "scroll as you go" or something.) Does that sound right? If so, I suggest a 12x1 display like the KTM-S1201.

From here on I'll assume that you plan to use an Arduino or other microprocessor...

The key processing logic in your program could just store up all of the keystrokes until you hit a special key (like "#") to signal that the entry is complete. (You could even treat a key like "*" as a Backspace.) The logic could then examine the sequence of stored numbers and "translate" it to a sequence of a "unlocking digits". If the sequence can't be translated, or the translated value does not match the unlocking code, you could make a beeping sound or display an error message on the display, etc. (If you think you might get at all fancy with the display, I recommend upgrading to one with more lines. (See http://tronixstuff.com/2011/01/08/tutorial-arduino-and-monochrome-lcds/)

With things being so slow at work lately, I would be happy to "step through" this project with you. I have a whole stockpile of parts that I can't seem to get my Boy Scouts or other neighborhood kids to take an interest in, so I could probably supply most of what you need for my cost (plus shipping). Let me know!

 

elec_mech

Joined Nov 12, 2008
1,500
Welcome to AAC.

I helped someone here with a similar project using a PICAXE. Check out this post. Includes parts list, schematic, code, and PCB layout. It uses a four digit LED display from Adafruit. You'd just need to change the code to reflect different numbers for the key presses.

Personally, I like PICAXE's over Arduino's because the code is easier to learn and understand, especially for those new to microcontrollers. However, I'm sure there are people here or on the Arduino forums if you decide to go that route instead.
 

JohnInTX

Joined Jun 26, 2012
4,787
@KerryJB @petro13 Welcome aboard!
I don't know why but KerryJB's pic reminded me of a former client - He came by the office with a box full of just that kind of stuff saying 'Here. You shouldn't have to to charge me much since I've done the hard part for you.'
I did say 'former client'.
 

KerryJB

Joined Dec 17, 2012
2
For example, the unlocking code is 1234, but the code numbers (that will be displayed on the screen) will not correspond to the numbers on the keypad, instead they will follow different rules, for example: 1 = 8,2 pressed in succession, 2 = 6, 3 = 4,1,5 pressed in succession etc.
After reading your explanation again, I see that I got things a little backwards. It sounds like you don't want to display the next digit on the display until a valid keystroke sequence has been detected. Thinking of it that way, the "4-digit display" makes sense. The user interface may be a little more tricky though.

Say the user punches in
8 ... 1 ... (oops, I meant to punch in "8 2") ... 8 ... 2 ...
  • Does the program "beep" as soon as the user punches in the 1, to let them know that "8 1" is an invalid sequence? (Providing "hints" like that could help a determined hacker eliminate a lot of invalid sequences quickly.)
  • With long-ish key sequences, the user can get lost more easily. Does it make sense to provide a Backspace key when they can't see what they've entered so far -- or would it be better to have a "start over on the current digit" key?
The nice thing about using a microcontroller for projects like this is that you can often fix (or completely change) the underlying logic without having to desolder / rewire / resolder. Of course, micros come with their own challenges....
 

jayanthd

Joined Jul 4, 2015
945
Hi

I can do this with a PIC12F1840. It is an 8 pin microcontroller. I will write code in mikroC PRO PIC / AVR Compiler. I will use one ADC pin to interface 4x4 keypad. You will need 8 diff value resistors 1% type to convert 8 pin keypad to 1 pin ADC keypad. I will use I2C LCD 16x2 or 16x1 or 8x1. I have written the I2C LCD library for mikroC Compilers. If you want to use 8 pin keypad then also it is possible. I will use mikroC Keypad and my I2C LCD library. You will then need a 14 pin PIC microcontroller. 8 pins of the PIC goes for keypad, 2 pins for power supply, 2 I2C pins (software I2C can be used if HW I2C is not available in the PIC) for the LCD.
 

BR-549

Joined Sep 22, 2013
4,928
I believe I would do it a little differently. I would connect the four horizontal keyboard wires to the first four inputs on port A. And connect the four vertical keyboard wires to the first four inputs on port B. (this can all be done on port A, but I want to eliminate any confusion)

I would use these 2 bit patterns to index a 4X4 memory array that contains the characters of the key.

Then I would set up an interrupt to occur with any change on the first four input pins on port A.

The interrupt will read both ports.......go to specified array location, and send character to display.

Now you have a regular keyboard and display.

Now you can write and add a security subroutine to the regular keyboard routine.

For instance, you could check for characters, like say for 4, 8s then 4, 4s in a row.......to lock the keyboard.

And another routine where only 9, 9s will unlock it.

You could add second functions to the keyboard too.

Just an idea.
 

Thread Starter

petro13

Joined Aug 21, 2015
2
Thank you all for your replies.

Say the user punches in
8 ... 1 ... (oops, I meant to punch in "8 2") ... 8 ... 2 ...
  • Does the program "beep" as soon as the user punches in the 1, to let them know that "8 1" is an invalid sequence? (Providing "hints" like that could help a determined hacker eliminate a lot of invalid sequences quickly.)
  • With long-ish key sequences, the user can get lost more easily. Does it make sense to provide a Backspace key when they can't see what they've entered so far -- or would it be better to have a "start over on the current digit" key?
You got it pretty much right, except that i'm expecting the program to beep only on valid sequences, and yes, a restart button is preferred.
Giving hints is not a problem as the purpose of the keylock is not security, i actually plan to incorporate it in an interactive game.
 

Art

Joined Sep 10, 2007
806
Pick a micro controller and commit!
Once you can properly scan a keypad and do a display, you’ll most likely be able to do the rest.
It’s just a matter of which micro, and this is a job suitable for even the cheapest and simplest.

A lot of development boards have keypads and displays and some outputs,
so you’d probably get away with doing no electronics at all for a one off unit.

Everyone has an opinion about which micro to use, but that’s no so important.
(and secretly everyone knows that pics are the best :D )

Generally you’d rotate a full code into a buffer and check all digits once the
enter key is pressed so as not to give the code away with timing and power attacks.
 
Top