One input keypad?


New Member
I got this idea from a post I had come across on this forum. I wasnt able to find the post again in the archives, neither was I able to find anything about anyone pursuing the concept. I decided to give it a whirl and this is what Ive come up with so far.

I am a beginner, so any info, advice, ideas and critiques are welcome.


Senior Member

I use one similar solution some time ago
<External Web Link>
but finally start use another solution with
modular keypad with CMOS gate inside.
This is a &quot;hardware&quot; solution like a &quot;doorlock key&quot;
because this can be changed by the final user
(common people NON programmer kind)by simply
insert another &quot;codekey&quot; in one socket.
But you resolve this issue &quot;more faster scan&quot;
better than me.

Last edited:


Senior Member
That's very impressive work. Thank you for posting it.

Good luck with your project. I hope that it will work out as well in hardware as it does on the sim. We'll all be looking forward to hearing of your progress.



Senior Member
Im noticed in the other thread of you're assembling one alarm device.
I've make the same project and work fine with one single 08 Picaxe.
1 delayed *Zone* for normally one enter path door with magnetical reed switch or PIR
1 Instant *Zone* for general purpose detectors.
1 tamper *Zone* for security purpose & reliability
1 Buzzer for noticed the status of the delay timer
1 relay output for dealing with Sirens & Strobes (or Phone dialer device)

This is the most small alarm I've build, and the most I sold.
Is *user friendly* and the code can be replaced *on site* by the owner, like one padlock.

Last edited:


Senior Member
Looked at your switch decoder in the first entry in this post.

It seems that by using the same 82 ohm resistor for each switch;

a. the ADC range is limited to around half that available.

b. the size of the steps between switches that the READADC is seeing diminishes rapidly and would appear to become unworkable after around 10 switches.

If you view the Spreadsheet (ADC Keypad Decoder Calculator) on Jon's site <A href='' Target=_Blank>External Web Link</a> you will see by scaling the resistor values along the serial chain you can achieve equal steps of around 15 with 16 switches. If you can tolerate step sizes of less than 15 (which you obviously can), then you could go to even more switches.

c. The resistor values are such that it would seem the PICAXE is sinking 30mA with only the last switch pressed.

I am interested to find what the practical minimum working ADC step is so do you have good reliability with the ADC step as low as 2.3?

I have also assumed that such low R values would introduce problems with resistor tolerance and switch contact resistances.

As you obviously have real world experience I would very much appreciate your comments on this



Edited by - BCJKiwi on 05/08/2007 12:32:28

Edited by - BCJKiwi on 05/08/2007 21:40:04


Senior Member

-Discontinued development due spec changes on the device needs

-Only one prototype working right now
(the other 2 burn it out)(the workspace room catch fire)

-As we don't need more than 10 buttons, don't try fit more

-CMOS 5 code digit keypad fit our specs
(4 code button Off, and 1 more button ON the system)

-CMOS are more user-frendly in case of change the code


Due the CMOS are cheaper than microcontroller, and this way
the *brain* of the device don't need control the pad, so less
memory space used, and can be controlled by any input.
Or as we do, switch ON-OFF the whole system.
As the final user isn't generally programmer kind, the option
of change byself the code is one heavy marketing issue.
"Simply buy another code combination, plug & Lock, like padlock"

But the prototype works fine, all the resistors are from the same
reel, and the buttons are identicals, so, no problems here.
Calibration was made with one reader module (Also burned out)
with 6 meters of multiwire with the shield tied to Ground.

Last edited:


New Member
The change of code your speaking of Sedeep, I assume you mean the keycode needed to unlock it. With your app, you have to buy another chip to change the code. I have code working right now with a regular keypad that allows me to change the PIN myself with no hardware change
Right now im storing the default '1234' code in the picaxe eeprom. After entering the PIN, the end user has the option of arming the system, changing the PIN, or canceling out of PIN operations.
Therefore, with the micrcontroller, you could do the same as you are now except end user could change PIN themselves without hardware change.


Technical Support
Staff member
sedeap : <i>As the final user isn't generally programmer kind, the option of change byself the code is one heavy marketing issue. &quot;Simply buy another code combination, plug &amp; Lock, like padlock&quot; </i>

I disagree and say it was an essential aspect to allow the user to change the code. Few will be programmers, so they need good instruction manuals and a simple means of re-programming.

From a security perspective I would never buy or accept a &quot;security code&quot; from anyone who could then know where that code was being used.

Edited by - hippy on 05/08/2007 23:49:46


Senior Member
WOW ! don't hit me... hehehe

The diferent society spectatives made the difference
Here don't want buggering whit program steps, simply want buy the solution ready made
So the Standard of security here are the Doorlocks or the padlocks, and all want
continue in that way. So if you try to sale one ";complicated device of security" you don't sale it.
One CMOS chip here cost 20cents U$S (0.20U$S)and the code card I give you for 2 U$s.
Is like buy one padlock, simply plug it, and NO program needed, I deliver 4 codecards
with each alarm device I sold.
If you want other, I make more. (Is more like Phone SimCard style )
So tell me... When you call one Locksmith... you *program* the lock???
Or him put another combination ready made and give you the keys???
With electronic security happen the same thing here, we have bulk of system devices
made from the most important manufacturers in the world (Motorola, Optronics, DSC, Crow,
Bosch, Notifier, etc) and the people still need one tecnician to install it.
So if they want to change their PIN still call me as tecnician to read the manuals and
change the programming code or the PIN. (the 90% of my clients who I install alarms on
his House or car)
So I start make one Little module *plug & lock* and was wonderful for this people
Simply change the card and it's all.
I have sold 89 Modules by now, usually to change some *complicated* fully featured
alarm central plenty of *programmable* options.
I install it, often changing almost new centrals, keeping the installation cabling and
sensors, sirens, ringbells, etc.

As say before... different society here.

I make the *core* or *brain* with microcontrollers (Almost all PICAXEs) and I know how
change one code, but the final user... don't, and don't want know how.
The simply idea of see themselves with a manual in hand and touching several buttons
in the right secuence... drive to hell.
Firstly I try to teach them how, later I rewrite some manuals for this people, and now
I sale them one diferent solution, and them... be happy with that.

Last edited:


Senior Member
Maybe I don't say the apropiate words and you don't be able to understand me.
I want say sorry, and forgive me, but i'm not a native english speaker, and don't live
in one english speaker country.
So bear with me, in some aspects I don't be able to translate in the right way what I
want say, but I make my best effort on that ( and in the rest of I do )
I open another Forum in Yahoo for Spanish and english speakers.
Feel free to visit me there and I come almost all days here to continue chatting in your

<External Web Link>
I offer to REV-ED's to translate the rest of the manuals to Spanish, but they don't
answer mi emails, but say *Any help is gratefully received!* so I'm start to help.

Last edited:


Senior Member
<i>&quot;Maybe I don't say the apropiate words and you don't be able to understand me.
I want say sorry, and forgive me, but i'm not a native english speaker, and don't live
in one english speaker country.&quot; </i>
No, sedeap, you said the words perfectly! I was laughing when I read your post, above.

Yes, I can understand your situation and business environment. And it's a very good business for you, too. Imagine - every time a customer wants to change a code, he calls you for a service call. You charge him travel time and your hourly rate to visit his site and push some buttons, or sell him another card or pad.

We have a saying here in the 'States: &quot;Nice work if you can get it!&quot; Congratulations!




Technical Support
Staff member
<i>As say before... different society here. </i>

Thank you for reminding me, and if it works and it is what people want I wish you every success with it.


Senior Member

"Not all that shine is Gold" (No todo lo que brilla es ORO)
is our *saying* here.

Only a customer want to change their code when have an issue related.
And I deliver 4 codecards with each device, so they can change 3 times by themselves.
this happen 1 time a year or something like that.
If you call one Locksmith, he bill you 20-40 U$S if change the bolt or the barrel.
I only earn 1.2U$S for each codecard and you can recycle them (or re-use them) several times for several years !!!!
The services of I most do are related to PIRs broken, powerplugs burned out, batterys
exausted or needs of relocation something...
But is a true issue here, If you have the money to avoid messing with manuals or steps
of programing anything, pay for it, and stay happy.
Some people (almost all be women) call me for one service to repair fuse shells blowed,
or ceilling-fan lamps burned out, or inclusive for one electric outlet malfunction.
Or males call me to their offices for service on telephone cabling, or wireless phone
with batterys flat dead.
My problem is that, I'm not enough thief to say them *is broken, buy me another*, and
my incomings are tight.
I must work 14 to 16 hours by day to pay the bills even saturdays and some sundays...
But I like what I do !
Make me feel good and open my mind to any new things.
I do services by any electric-electronic devices, phone-comunications, alarm-security,
CCTV-cameras, Access control, PC related hardware, office equipment and networking.
Mostly on Small offices or Schools, but the people working there, call me for their own
house or weekend club-house. (and the families of them)
So the 99% of my clients are recommended by another knowed to call me.

Last edited:


Senior Member
Thanks hippy, I do my best effort.
have you one landscape photo of your neighbourhood?
or any other place around to see it?

If you don't have one free place to hang it up, send it to my forum or email.

TNX :eek: pal.

Spanish Forum of Picaxe --> <External Web Link>
or sedeap <at> yahoo dot com dot ar

Last edited:


New Member
Well gentlemen, the results are in. I believe we have a winner!

I was very happy with the results of the keypad. After some testing to find the right range, I believe this will be a better alternative(if not a replacement) for the matrix keypad.


Senior Member
&quot;Good Job!&quot; as they say.

Will look forward to the results of switch ADC range reliability testing.




Senior Member
Jon... thanks for sharing your work - one thing that may be problematic is the push button resistance with time - this effect could be reduced by a series string of resistors with taps - then the PBs could go to relatively high resistance of the ADC input. Disadvantages would be constant current in the divider string amongst other changes.


Technical Support
Staff member
Well done for taking the time to not just consider the idea but test it out and prove it works.

If you are not using Data Eeprom you could map the ADC value into an Eeprom read and get the key press number back very quickly and with minimal code space ...<code><pre><font size=2 face='Courier'> READADC pin, keyAdc
READ keyAdc, keyNumber </font></pre></code> Even if you need to use Data Eeprom ( for a PIN etc ) it may be possible to map the ADC into unused area by some clever number shifting or processing and still keep the speed up and space used down.


I wrote some code up once for a one button for alphanumerical entry. But one does have to know Mores Code though.


Senior Member
Look at the spreadsheet on jon's site where I have alternate calculations including matrix keypad and serial resistor string calculators as well as the parallel arrangement favoured by Jon.

I expressed the same concerns. I believe greater long term stability would be achieved by using higher value resistors throughout as the switch resistance becomes a smaller portion of the resistance values in play and thus have less impact.




Senior Member
BCJ... I've repaired quite a few devices with failed or partially failed PB switches which is why I mentioned it... In looking at keyboards trying to get reliable PBs I've seen optical interrupters, hall effect devices and a whole lot of mechanical contacts... it's an ongoing struggle!

As the bard said --- &quot;PB or not PB - that [or what] is the input!&quot;


New Member
BCJ and Premelec, correct me if Im wrong.

My understanding of your concern is that you believe the switch contacts will build up resistance over time? IE my lowest combo uses a 1k and a 39 ohm, if the switch developed another 30 ohms of resistance over time it would change my ADC.
Your suggestion is to use such high resistance resistors that the contact resistance buildup over time is such a small portion of the resistance that it has virtually no effect.
Is this correct? If it is, what kind of contact resistances could we expect to see over time.
Reading some of BCJ's previous posts in the other topic, I see where he talked about this before. I failed to see what you were speaking of. I understand now what you were saying about the higher resistances.
If I could get some feedback about how much of a buildup I could expect to see on contacts, I could change the values accordingly.
Actually, if you take the resistance I use now and multiply them all(including dividing resistor) by 10 or even 100, you will come out with the same voltages and ADC values I get now.
Now that I understand the contact resistance concern, I believe Ill raise them by a factor of 100.
Doing so should minimize the effects of any changes in contact resistance over time. Yes?
I apologize BCJ for not comprehending your concern earlier, but your exchange with SeDeap sparked it for me.
It is a valid concern which I think can now be remedied quite easily.
Thanks Guys.

Ive posted a new schematic with the higher resistances to the downloads section of my site.

Edited by - Jon Henry on 07/08/2007 23:12:57


Senior Member
Hi Jon, Since the ADC input is ratiometric with the PICAXE voltage you could use a series string of identical resistors - the number being suitable to the number of SPST tap switches... for assured accuracy you'd want .5(NxRval) &lt;10,000ohms [I got this by intuitive process - you might want to calculate it for the various taps - the string at the tap being composed of R1 &amp; R2 [R1+R2 = string total] and the source resistance being R1R2/(R1+R2) - their parallel resistance... Note I'm not dealing with the fine points of a matrix select switch setup... the ADC input is around a megohm perhaps so a bit of series switch resistance won't affect accuracy so much.

Anyhow you seem to be doing fine with the development so continue with confidence!


Senior Member
Jon - Happy to see you pick up on the concern - understanding fully what other people mean is always difficult.

As advised before, Some standard keypad spec sheets advertise 'contact resestance &lt; 200Ohms - i.e up to 200 ohms per switch!. So the resistor values should be such that a change from 0 to 200ohms at the contact, when added to the resistor value, has no significant effect on the ADC value seen by the PICAXE READADC.

If you would look at the spreadsheets referred to above and kindly hosted by Jon on his download page, you will see that using the same value resistors along the string does not result in an even spread of ADC values. To get even intervals between ADC values across all switches you need to increase the resistances along the chain. Rather than tying to explain it in detail here, have a look at the calcs.




Senior Member

Jon's nice one-wire keypad can be integrated into application programs with more flexibility and programming ease if the pressing of any button generates an interrupt as well, because the program then does not need to poll the adc input line continuously. The interrupt routine can read the keys instead, leaving the main program structure much simpler.

A simple comparator circuit connected to the ADC input could do this; the comparator should have an low output when no button is pressed (i.e. the ADC input is at 0V) or when the ADC input voltage is somewhat less (due to resistor tolerances) than the lowest input voltage (In Jon's example it corresponds with the leftmost button with 24K resistance, leading to 0.2V). So you may choose the comparator tripping point safely at 0.1V, i.e. any input voltage higher than 0.1V should generate a high comparator output.

The comparator output could be tied to an interrupt input in the following ways:
- directly (if there are no other interrupt sources)
- diode mixing (simple solution when more interrupt lines are present in the system)
- Use an MCP23008 or MCP23017 I/O part to catch the interrupt (very handy for more complex interrupt handling)



Senior Member
Jon, two more things to consider;

1. Detecting multiple key presses;
Ran out a truth table for all single and double keypresses where the keys are adjacent (Horizontal or vertical)to each other and calculating the READADC value. Have applied this to both the parallel and serial resistor models and then sorted the ADC values to get an idea of what sort of gaps there were.
With the full table it looked pretty hopeless but with just the adjacent keys the parallel model using the resistor values in my spreadsheet will work well. For the serial model there are about 4 keys that won't be fully isolated. As you indicated earlier, real world measurements will confirm this.

Have uploaded this to your site so you can 'plug in' your resistor values.

2. Key resistance;
Pulled apart a recently failed Digital phone off a brand name Business PABX system. This phone has done around 8 years work. It's a well-made phone but internally has the typical matrix keyad arrangement of flexible elements pressing a conductive pad against tracks on the board.
Previously unused switches (features not in the phone) read 100 ohms with a variation of around +- 2 ohms over multiple presses. Keys that had done a lot of work read around 105 ohms +- 2.

Also checked out a number of well used TACT type switches off old panels and they all read less than 1 ohm contact resistance.


Edited by - BCJKiwi on 08/08/2007 13:51:46

Edited by - BCJKiwi on 08/08/2007 15:02:44


New Member
It's a god idea to wire a keypad using only one input terminal of your PICAXE, but I think the program may be easier. Just replace all comparations for only one instruction: Let b1=b0*10/162.



New Member
Jauma, again Ive gotten this suggestion before without realizing it from BeanieBots. If im correct your meaning something like this:

readadc 0,b0
let b1=b0*10/82
if b1&gt;=1 and b1&lt;=2 then display
let b1=b0*10/125
if b1&gt;=3 and b1&lt;=4 then display
let b1=b0*100/1385
if b1&gt;=5 and b1&lt;=8 then display
let b1=b0*10/145
if b1&gt;=9 and b1&lt;=16 then display
goto main

serout 7,N2400,(254,128,#b1,&quot; &quot;)
goto main

It seems theoretically feasible, my concern would be with simultaneous key pressings. They would register as actual numbers. In most applications, it probably wouldnt matter. But for mine, it does.
Im doing an alarm, when my end-user presses a key, the number doesnt show up on the screen and asterisk does. So they would have no clue if the correct number was input. Three wrong PIN entries and the alarm sounds. Thats why simultaneous pressings are important to me.
Now in apps where the user would actually see the number, Im sure this would work fine. It certainly uses less code and would have plenty of scan speed.

This code works with plenty of speed on my current ADC circuit except for one issue. I would have to change the first four key resistances to get an equation that works. Unless someone knows math better than I(doesn't take much), I don't think I can make an equation for the first four that works.
Again, I think this is very feasible if simultaneous pressings arent a problem.
I apologize to BeanieBots for not catching on earlier but better late than never.

Edited by - Jon Henry on 08/08/2007 20:40:09

Edited by - Jon Henry on 08/08/2007 20:41:18

Edited by - Jon Henry on 09/08/2007 04:02:23


Senior Member
BCJ.. I was only suggesting a series string divider with taps - the switches connect to the adc input - the switch common line would then be going to the ADC input. In the simplest case R and R in series provide two ADC values full volts and half volts. This can be extended to R...R...R string providing N discrete values. This is how digital potentiometers and 'Trimdacs' work.
Simply a bunch of taps emulating a potentiometer... The current flowing through each resistor is the same [except small tap current] and so the voltage change across each is the same... or non-linear if you wish to choose different values of resistance for each tap. A versatile structure. The weighted resistor scheme Jon shows works too of course...


Senior Member
I figure you mean the V+ goes into one end of the serial resisitor chain and the other end to 0v. There would be one more resistor than taps to ensure all tap ADC values (switches placed at resistor junctions) are between V+ and 0v.

Something like this?

            |          |          |          |          |
           sw          sw         sw         sw         sw
            |          |          |          |          |
This works really well and is simple to set up, resistor values don't matter if they are all the same. It is a great arrangement if you know only one switch will be pressed at any time. If adjacent keys are pressed together I can't see any way to sort them out as the ADC values produced are virtually the same as the single key values. You do get a just usable difference with only 4 or maybe five keys but as the number of keys increases the resistor that is shorted out by the adjacent keys is a very small part of the divider network and so the ADC value is near enough the same as when it is not shorted.

Do you have an answer for this issue?

The type of 'parallel' chain Jon has decided on is the simplest to produce the scaled values for, and gives the cleanest distinction between ADC values, and, with careful selection of resistor values, when adjacent keys are pressed they can be detected.


Edited by - BCJKiwi on 09/08/2007 13:21:35
Last edited:


Senior Member
No... :) - but there _are_ answers...

Multiple keys being pressed is always a problem - e.g. when a cat walks across your keyboard.... A solution is to look for any change - then accept and lock in the first value seen as a legitimate input [in expected range for the divider taps &amp; resistor accuracies] - then scan again. In the case of series Rs I've mentioned pushing two or more switches at once will distort the values over the whole divider string to invalid ones - easy for a few keys but harder to detect as you get to 255 keys...

Good luck with it - electronics has so many ways to skin that cat walking on the keyboard!

Edited by - premelec on 09/08/2007 15:28:25

Edited by - premelec on 09/08/2007 22:18:31


Senior Member
Have reworked and refined the Calculators for different key decoding arrangements for the '1 wire' keypad. (Also corrected a few calculation errors!).

This covers 4 different decoding arrangements and discusses some of the issues involved in application.

Appreciate any constructive feedback and suggestions for improvement.

Calculator is here kindly being hosted on Jon's site.

One of the outcomes of this analysis work is that the ideal of being able to clearly separate the desired single keypress from any two adjacent keys pressed together seems just as elusive as ever. With a standard 4 x 4 16 key array, just considering the single key, and immediately adjacent horizontal and vertical keys pressed together, there are 40 combinations to consider. When analysing the ADC values resulting from resistor arrays giving good separation of values of ADC, and the ADC values of the unwanted multi-key presses, between 10 and 20 of the 40 combinations are within a range of +-2 of another ADC value. The number depends on the resistor array type and the resistor values selected.

Would be interested in any suggestions as to how one might realistically achieve this 'filter' via programming means. Since we are dealing with READADC the customary key debounce/delay type systems would appear not to apply.

Jon has promised to give us some feedback on what he finds to be the minimum practical range (or sensitivity) of the ADC values tested for in the program once he has some practical results from his working system.

Have carried out some testing on a prototyping board and 14M reading back the ADC.
Find the E24 series resistor tolerances (5%) and PICAXE ADC INPUT impedance and whatever other variations are coming into play, that the theory is off by up to 2 ADC values even after adjusting for the actual resistor values compared to the ADC value output by the 14M.

Accordingly I doubt that it is practical to rely on separating out the ADC reads of multi key presses.

Front page and 'Divider Chain sheets have been further modified - Current version 3.1

Edited by - BCJKiwi on 11/08/2007 15:54:13
Last edited:


Senior Member
I think the usual solution is to scan [multiplex] one axis thereby limiting the number of keys in play at any one time... But I don't know this is the case...


New Member
Ive posted the results of my range testing as well another concept.
<A href='' Target=_Blank>External Web Link</a>


Senior Member
Premelec - That works if you have more than '1 wire' unless you mean something by multiplex that I have not grasped.

Latest version of the Calculators - V 3.2 includes a number of refinements of not much significance but also an adjustment to the formulas to provide for the actual step number being 256 (0 to 255) and not the same as the highest value of 255.

Have posted test results from a breadboard set up of 16 keys using the 'divider chain' arrangement - the equivalent of a potentiometer - as this is the arrangemnt I would go for as it is the simplest by far to build and test and doesn't really require any real design as all R values are the same and gives a nice even spread of ADC values.
Thanks to Premelec for the advice on this alternative. Results are from a setup using a 14M of a LM7805 supply. Measurments via serout to an LCD, and a digital multimeter.

Lastest revision, and these results, posted on Jon's site again. Results are in 'Divider chain.pdf' <A href='' Target=_Blank>External Web Link</a>

These results show good correlation between calculations and real world. However there are no actual switches involved here but with nominal values of 10k in th resistors, switch resistance should not be an issue.

The multi key press should not be a major issue for the PIN. If you adopt the standard computer industry practice when setting a new password then you should not have a problem. The procedure is to store the PIN and then to require it to be re-entered. If they are not the same then you clear them and start over.

As you already have three tries for the PIN entry to gain access, then the user would have to be pretty clumsy (or drunk?) to get it wrong three times over. Digital locks often force a delay after a wrong entry before accepting another entry. Im not sure why this is done but it does have the effect of making you think a bit before the system resets the input for you to try again.

Perhaps if none of these strategies work, the alarm should go off!


Edited by - BCJKiwi on 12/08/2007 07:23:08