keypad help

skipoaxe

New Member
Hi All

I'm looking for some help

I have a 3x4 keypad sending each key stroke into b1 which works fine and displays on a LCD.

the problem I'm having is that I need to combine each key stroke into a combined number not added,

eg. key press 1 then key press 2 then key press 3 to give me the number 123 not 1+2+3 = 6

any ideas?

Thanks Stuart
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

w0 = 0
w0 = w0 * 10 + keyValue1
w0 = w0 * 10 + keyValue2
w0 = w0 * 10 + keyValue3

That can be optimised to ...

w0 = keyValue1 * 10 + keyValue2 * 10 + keyValue3

Note you need to use a 'w' word variable to be able to store up to 999
 

skipoaxe

New Member
Thanks Hippy

I thought about it over night and came to a similar conclusion but yours is nice and clean.
I've thrown mine out and your code is doing the job well.

appreciate the help

Thanks Stuart
 
Top